Skip to content

Commit

Permalink
Merge pull request #254 from leozeli/master
Browse files Browse the repository at this point in the history
fix(RueidisStore): add case to detail with  JSON, Raw []byte, and Vec…
  • Loading branch information
eko authored Jul 12, 2024
2 parents 78b7afe + 6177036 commit 4e8b44d
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 4e8b44d

Please sign in to comment.