1
0
mirror of https://github.com/redis/go-redis.git synced 2025-06-12 14:21:52 +03:00

feat: enable struct on HSet

This commit is contained in:
wjdqhry
2021-12-17 11:54:43 +09:00
parent e9a8bb4f86
commit bf334e7738
2 changed files with 44 additions and 0 deletions

View File

@ -197,6 +197,20 @@ func ExampleClient_SetEX() {
}
}
func ExampleClient_HSet() {
type Items struct {
Key1 string `json:"key1"`
Key2 string `json:"key2"`
}
items := Items{"field1", "field2"}
// Last argument is expiration. Zero means the key has no
// expiration time.
err := rdb.HSet(ctx, "key", items).Err()
if err != nil {
panic(err)
}
}
func ExampleClient_Incr() {
result, err := rdb.Incr(ctx, "counter").Result()
if err != nil {