mirror of
https://github.com/redis/go-redis.git
synced 2025-06-12 14:21:52 +03:00
Add ScanType command to Scan with 'type' option
As of version 6.0 you can use this 'type' option to ask SCAN to only return objects that match a given type, allowing you to iterate through the database looking for keys of a specific type.
This commit is contained in:
@ -770,6 +770,18 @@ var _ = Describe("Commands", func() {
|
||||
Expect(cursor).NotTo(BeZero())
|
||||
})
|
||||
|
||||
It("should ScanType", func() {
|
||||
for i := 0; i < 1000; i++ {
|
||||
set := client.Set(ctx, fmt.Sprintf("key%d", i), "hello", 0)
|
||||
Expect(set.Err()).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
keys, cursor, err := client.ScanType(ctx, 0, "", 0, "string").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(keys).NotTo(BeEmpty())
|
||||
Expect(cursor).NotTo(BeZero())
|
||||
})
|
||||
|
||||
It("should SScan", func() {
|
||||
for i := 0; i < 1000; i++ {
|
||||
sadd := client.SAdd(ctx, "myset", fmt.Sprintf("member%d", i))
|
||||
|
Reference in New Issue
Block a user