Skip to content

Commit 0ea1b15

Browse files
authored
Merge branch 'master' into hash-expiration-commands-v7.4-comments
2 parents 7944d87 + 030c184 commit 0ea1b15

File tree

7 files changed

+144
-5
lines changed

7 files changed

+144
-5
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,7 @@ The core team regularly looks at pull requests. We will provide
112112
feedback as soon as possible. After receiving our feedback, please respond
113113
within two weeks. After that time, we may close your PR if it isn't
114114
showing any activity.
115+
116+
## Support
117+
118+
Maintainers can provide limited support to contributors on discord: https://discord.gg/W4txy5AeKM

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33
[![build workflow](https://github.com/redis/go-redis/actions/workflows/build.yml/badge.svg)](https://github.com/redis/go-redis/actions)
44
[![PkgGoDev](https://pkg.go.dev/badge/github.com/redis/go-redis/v9)](https://pkg.go.dev/github.com/redis/go-redis/v9?tab=doc)
55
[![Documentation](https://img.shields.io/badge/redis-documentation-informational)](https://redis.uptrace.dev/)
6+
[![Go Report Card](https://goreportcard.com/badge/github.com/redis/go-redis/v9)](https://goreportcard.com/report/github.com/redis/go-redis/v9)
67
[![codecov](https://codecov.io/github/redis/go-redis/graph/badge.svg?token=tsrCZKuSSw)](https://codecov.io/github/redis/go-redis)
7-
[![Chat](https://discordapp.com/api/guilds/752070105847955518/widget.png)](https://discord.gg/rWtp5Aj)
8+
9+
[![Discord](https://img.shields.io/discord/697882427875393627.svg?style=social&logo=discord)](https://discord.gg/W4txy5AeKM)
10+
[![Twitch](https://img.shields.io/twitch/status/redisinc?style=social)](https://www.twitch.tv/redisinc)
11+
[![YouTube](https://img.shields.io/youtube/channel/views/UCD78lHSwYqMlyetR0_P4Vig?style=social)](https://www.youtube.com/redisinc)
12+
[![Twitter](https://img.shields.io/twitter/follow/redisinc?style=social)](https://twitter.com/redisinc)
13+
[![Stack Exchange questions](https://img.shields.io/stackexchange/stackoverflow/t/go-redis?style=social&logo=stackoverflow&label=Stackoverflow)](https://stackoverflow.com/questions/tagged/go-redis)
814

915
> go-redis is the official Redis client library for the Go programming language. It offers a straightforward interface for interacting with Redis servers.
1016
@@ -44,7 +50,7 @@ in the `go.mod` to `go 1.24` in one of the next releases.
4450
## Resources
4551

4652
- [Discussions](https://github.com/redis/go-redis/discussions)
47-
- [Chat](https://discord.gg/rWtp5Aj)
53+
- [Chat](https://discord.gg/W4txy5AeKM)
4854
- [Reference](https://pkg.go.dev/github.com/redis/go-redis/v9)
4955
- [Examples](https://pkg.go.dev/github.com/redis/go-redis/v9#pkg-examples)
5056

command.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3831,7 +3831,8 @@ func (cmd *MapStringStringSliceCmd) readReply(rd *proto.Reader) error {
38313831
}
38323832

38333833
// -----------------------------------------------------------------------
3834-
// MapStringInterfaceCmd represents a command that returns a map of strings to interface{}.
3834+
3835+
// MapMapStringInterfaceCmd represents a command that returns a map of strings to interface{}.
38353836
type MapMapStringInterfaceCmd struct {
38363837
baseCmd
38373838
val map[string]interface{}

commands.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ func appendArg(dst []interface{}, arg interface{}) []interface{} {
8181
return dst
8282
case time.Time, time.Duration, encoding.BinaryMarshaler, net.IP:
8383
return append(dst, arg)
84+
case nil:
85+
return dst
8486
default:
8587
// scan struct field
8688
v := reflect.ValueOf(arg)
@@ -330,7 +332,7 @@ func (info LibraryInfo) Validate() error {
330332
return nil
331333
}
332334

333-
// Hello Set the resp protocol used.
335+
// Hello sets the resp protocol used.
334336
func (c statefulCmdable) Hello(ctx context.Context,
335337
ver int, username, password, clientName string,
336338
) *MapStringInterfaceCmd {

commands_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7209,6 +7209,17 @@ var _ = Describe("Commands", func() {
72097209
Expect(err).NotTo(HaveOccurred())
72107210
Expect(vals).To(Equal([]interface{}{int64(12), proto.RedisError("error"), "abc"}))
72117211
})
7212+
7213+
It("returns empty values when args are nil", func() {
7214+
vals, err := client.Eval(
7215+
ctx,
7216+
"return {ARGV[1]}",
7217+
[]string{},
7218+
nil,
7219+
).Result()
7220+
Expect(err).NotTo(HaveOccurred())
7221+
Expect(vals).To(BeEmpty())
7222+
})
72127223
})
72137224

72147225
Describe("EvalRO", func() {
@@ -7232,6 +7243,17 @@ var _ = Describe("Commands", func() {
72327243
Expect(err).NotTo(HaveOccurred())
72337244
Expect(vals).To(Equal([]interface{}{int64(12), proto.RedisError("error"), "abc"}))
72347245
})
7246+
7247+
It("returns empty values when args are nil", func() {
7248+
vals, err := client.EvalRO(
7249+
ctx,
7250+
"return {ARGV[1]}",
7251+
[]string{},
7252+
nil,
7253+
).Result()
7254+
Expect(err).NotTo(HaveOccurred())
7255+
Expect(vals).To(BeEmpty())
7256+
})
72357257
})
72367258

72377259
Describe("Functions", func() {

doctests/home_json_example_test.go

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,107 @@ func ExampleClient_search_json() {
227227
// London - 1
228228
// Tel Aviv - 2
229229
}
230+
231+
func ExampleClient_search_hash() {
232+
ctx := context.Background()
233+
234+
rdb := redis.NewClient(&redis.Options{
235+
Addr: "localhost:6379",
236+
Password: "", // no password docs
237+
DB: 0, // use default DB
238+
Protocol: 2,
239+
})
240+
241+
// REMOVE_START
242+
rdb.Del(ctx, "huser:1", "huser:2", "huser:3")
243+
rdb.FTDropIndex(ctx, "hash-idx:users")
244+
// REMOVE_END
245+
246+
// STEP_START make_hash_index
247+
_, err := rdb.FTCreate(
248+
ctx,
249+
"hash-idx:users",
250+
// Options:
251+
&redis.FTCreateOptions{
252+
OnHash: true,
253+
Prefix: []interface{}{"huser:"},
254+
},
255+
// Index schema fields:
256+
&redis.FieldSchema{
257+
FieldName: "name",
258+
FieldType: redis.SearchFieldTypeText,
259+
},
260+
&redis.FieldSchema{
261+
FieldName: "city",
262+
FieldType: redis.SearchFieldTypeTag,
263+
},
264+
&redis.FieldSchema{
265+
FieldName: "age",
266+
FieldType: redis.SearchFieldTypeNumeric,
267+
},
268+
).Result()
269+
270+
if err != nil {
271+
panic(err)
272+
}
273+
// STEP_END
274+
275+
user1 := map[string]interface{}{
276+
"name": "Paul John",
277+
"email": "[email protected]",
278+
"age": 42,
279+
"city": "London",
280+
}
281+
282+
user2 := map[string]interface{}{
283+
"name": "Eden Zamir",
284+
"email": "[email protected]",
285+
"age": 29,
286+
"city": "Tel Aviv",
287+
}
288+
289+
user3 := map[string]interface{}{
290+
"name": "Paul Zamir",
291+
"email": "[email protected]",
292+
"age": 35,
293+
"city": "Tel Aviv",
294+
}
295+
296+
// STEP_START add_hash_data
297+
_, err = rdb.HSet(ctx, "huser:1", user1).Result()
298+
299+
if err != nil {
300+
panic(err)
301+
}
302+
303+
_, err = rdb.HSet(ctx, "huser:2", user2).Result()
304+
305+
if err != nil {
306+
panic(err)
307+
}
308+
309+
_, err = rdb.HSet(ctx, "huser:3", user3).Result()
310+
311+
if err != nil {
312+
panic(err)
313+
}
314+
// STEP_END
315+
316+
// STEP_START query1_hash
317+
findPaulHashResult, err := rdb.FTSearch(
318+
ctx,
319+
"hash-idx:users",
320+
"Paul @age:[30 40]",
321+
).Result()
322+
323+
if err != nil {
324+
panic(err)
325+
}
326+
327+
fmt.Println(findPaulHashResult)
328+
// >>> {1 [{huser:3 <nil> <nil> <nil> map[age:35 city:Tel Aviv...
329+
// STEP_END
330+
331+
// Output:
332+
// {1 [{huser:3 <nil> <nil> <nil> map[age:35 city:Tel Aviv email:[email protected] name:Paul Zamir]}]}
333+
}

hash_commands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ func (c cmdable) HGetEX(ctx context.Context, key string, fields ...string) *Stri
520520
return cmd
521521
}
522522

523-
// ExpirationType represents an expiration option for the HGETEX command.
523+
// HGetEXExpirationType represents an expiration option for the HGETEX command.
524524
type HGetEXExpirationType string
525525

526526
const (

0 commit comments

Comments
 (0)