Skip to content

Commit

Permalink
docs: add instructions for the HSet api (redis#2503)
Browse files Browse the repository at this point in the history
Signed-off-by: monkey92t <[email protected]>
Co-authored-by: Chayim <[email protected]>
  • Loading branch information
monkey92t and chayim authored Mar 28, 2023
1 parent 42d730c commit 4c72b4e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ func (c cmdable) HMGet(ctx context.Context, key string, fields ...string) *Slice
// Playing struct With "redis" tag.
// type MyHash struct { Key1 string `redis:"key1"`; Key2 int `redis:"key2"` }
//
// - HSet("myhash", MyHash{"value1", "value2"})
// - HSet("myhash", MyHash{"value1", "value2"}) Warn: redis-server >= 4.0
//
// For struct, can be a structure pointer type, we only parse the field whose tag is redis.
// if you don't want the field to be read, you can use the `redis:"-"` flag to ignore it,
Expand All @@ -1453,7 +1453,10 @@ func (c cmdable) HMGet(ctx context.Context, key string, fields ...string) *Slice
// string, int/uint(8,16,32,64), float(32,64), time.Time(to RFC3339Nano), time.Duration(to Nanoseconds ),
// if you are other more complex or custom data types, please implement the encoding.BinaryMarshaler interface.
//
// Note that it requires Redis v4 for multiple field/value pairs support.
// Note that in older versions of Redis server(redis-server < 4.0), HSet only supports a single key-value pair.
// redis-docs: https://redis.io/commands/hset (Starting with Redis version 4.0.0: Accepts multiple field and value arguments.)
// If you are using a Struct type and the number of fields is greater than one,
// you will receive an error similar to "ERR wrong number of arguments", you can use HMSet as a substitute.
func (c cmdable) HSet(ctx context.Context, key string, values ...interface{}) *IntCmd {
args := make([]interface{}, 2, 2+len(values))
args[0] = "hset"
Expand Down

0 comments on commit 4c72b4e

Please sign in to comment.