Skip to content

Commit

Permalink
upgrade redis client version (#870)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenghaoz authored Oct 17, 2024
1 parent 7107d04 commit 2d59d47
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 27 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ require (
github.com/prometheus/client_golang v1.13.0
github.com/rakyll/statik v0.1.7
github.com/redis/go-redis/extra/redisotel/v9 v9.5.3
github.com/redis/go-redis/v9 v9.7.0-beta.1
github.com/redis/go-redis/v9 v9.7.0
github.com/samber/lo v1.38.1
github.com/schollz/progressbar/v3 v3.9.0
github.com/sclevine/yj v0.0.0-20210612025309-737bdf40a5d1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,8 @@ github.com/redis/go-redis/extra/rediscmd/v9 v9.5.3 h1:1/BDligzCa40GTllkDnY3Y5DTH
github.com/redis/go-redis/extra/rediscmd/v9 v9.5.3/go.mod h1:3dZmcLn3Qw6FLlWASn1g4y+YO9ycEFUOM+bhBmzLVKQ=
github.com/redis/go-redis/extra/redisotel/v9 v9.5.3 h1:kuvuJL/+MZIEdvtb/kTBRiRgYaOmx1l+lYJyVdrRUOs=
github.com/redis/go-redis/extra/redisotel/v9 v9.5.3/go.mod h1:7f/FMrf5RRRVHXgfk7CzSVzXHiWeuOQUu2bsVqWoa+g=
github.com/redis/go-redis/v9 v9.7.0-beta.1 h1:x8FaPEIjBIjzkO3irDARTa/yemsNeHmni16UcVK/ttE=
github.com/redis/go-redis/v9 v9.7.0-beta.1/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E=
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
Expand Down
37 changes: 13 additions & 24 deletions storage/cache/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,19 @@ func (r *Redis) Init() error {
}
// create index
if !lo.Contains(indices, r.DocumentTable()) {
_, err = r.client.Do(context.TODO(), "FT.CREATE", r.DocumentTable(),
"ON", "HASH", "PREFIX", "1", r.DocumentTable()+":", "SCHEMA",
"collection", "TAG",
"subset", "TAG",
"id", "TAG",
"score", "NUMERIC", "SORTABLE",
"is_hidden", "NUMERIC",
"categories", "TAG", "SEPARATOR", ";",
"timestamp", "NUMERIC", "SORTABLE").
Result()
// Blocked by https://github.com/redis/go-redis/issues/3150
//_, err = r.client.FTCreate(context.TODO(), r.DocumentTable(),
// &redis.FTCreateOptions{
// OnHash: true,
// Prefix: []any{r.DocumentTable() + ":"},
// },
// &redis.FieldSchema{FieldName: "collection", FieldType: redis.SearchFieldTypeTag},
// &redis.FieldSchema{FieldName: "subset", FieldType: redis.SearchFieldTypeTag},
// &redis.FieldSchema{FieldName: "id", FieldType: redis.SearchFieldTypeTag},
// &redis.FieldSchema{FieldName: "score", FieldType: redis.SearchFieldTypeNumeric, Sortable: true},
// &redis.FieldSchema{FieldName: "is_hidden", FieldType: redis.SearchFieldTypeNumeric},
// &redis.FieldSchema{FieldName: "categories", FieldType: redis.SearchFieldTypeTag, Seperator: ";"},
// &redis.FieldSchema{FieldName: "timestamp", FieldType: redis.SearchFieldTypeNumeric, Sortable: true},
//).Result()
_, err = r.client.FTCreate(context.TODO(), r.DocumentTable(),
&redis.FTCreateOptions{
OnHash: true,
Prefix: []any{r.DocumentTable() + ":"},
},
&redis.FieldSchema{FieldName: "collection", FieldType: redis.SearchFieldTypeTag},
&redis.FieldSchema{FieldName: "subset", FieldType: redis.SearchFieldTypeTag},
&redis.FieldSchema{FieldName: "id", FieldType: redis.SearchFieldTypeTag},
&redis.FieldSchema{FieldName: "score", FieldType: redis.SearchFieldTypeNumeric, Sortable: true},
&redis.FieldSchema{FieldName: "is_hidden", FieldType: redis.SearchFieldTypeNumeric},
&redis.FieldSchema{FieldName: "categories", FieldType: redis.SearchFieldTypeTag, Separator: ";"},
&redis.FieldSchema{FieldName: "timestamp", FieldType: redis.SearchFieldTypeNumeric, Sortable: true},
).Result()
if err != nil {
return errors.Trace(err)
}
Expand Down

0 comments on commit 2d59d47

Please sign in to comment.