Skip to content

Commit

Permalink
fix(RueidisStore): add case to detail with JSON, Raw []byte, and Vect…
Browse files Browse the repository at this point in the history
…or Similarity Search
  • Loading branch information
leozeli committed Jun 27, 2024
1 parent 78b7afe commit 6177036
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions store/rueidis/rueidis.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,18 @@ func (s *RueidisStore) GetWithTTL(ctx context.Context, key any) (any, time.Durat
func (s *RueidisStore) Set(ctx context.Context, key any, value any, options ...lib_store.Option) error {
opts := lib_store.ApplyOptionsWithDefault(s.options, options...)
ttl := int64(opts.Expiration.Seconds())
cmd := s.client.B().Set().Key(key.(string)).Value(value.(string)).ExSeconds(ttl).Build()
var cmd rueidis.Completed
switch value.(type) {
case string:
cmd = s.client.B().Set().Key(key.(string)).Value(value.(string)).ExSeconds(ttl).Build()

case []byte:
cmd = s.client.B().Set().Key(key.(string)).Value(rueidis.BinaryString(value.([]byte))).ExSeconds(ttl).Build()
}
err := s.client.Do(ctx, cmd).Error()
if err != nil {
return err
}

if tags := opts.Tags; len(tags) > 0 {
s.setTags(ctx, key, tags)
}
Expand Down

0 comments on commit 6177036

Please sign in to comment.