1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Add scan iterator.

This commit is contained in:
Dimitrij Denissenko
2016-04-13 09:52:47 +01:00
committed by Vladimir Mihailenco
parent 889409de38
commit 7456a0e473
6 changed files with 216 additions and 18 deletions

View File

@ -318,7 +318,7 @@ func (c *commandable) Type(key string) *StatusCmd {
return cmd
}
func (c *commandable) Scan(cursor int64, match string, count int64) *ScanCmd {
func (c *commandable) Scan(cursor int64, match string, count int64) Scanner {
args := []interface{}{"SCAN", cursor}
if match != "" {
args = append(args, "MATCH", match)
@ -328,10 +328,13 @@ func (c *commandable) Scan(cursor int64, match string, count int64) *ScanCmd {
}
cmd := NewScanCmd(args...)
c.Process(cmd)
return cmd
return Scanner{
client: c,
ScanCmd: cmd,
}
}
func (c *commandable) SScan(key string, cursor int64, match string, count int64) *ScanCmd {
func (c *commandable) SScan(key string, cursor int64, match string, count int64) Scanner {
args := []interface{}{"SSCAN", key, cursor}
if match != "" {
args = append(args, "MATCH", match)
@ -341,10 +344,13 @@ func (c *commandable) SScan(key string, cursor int64, match string, count int64)
}
cmd := NewScanCmd(args...)
c.Process(cmd)
return cmd
return Scanner{
client: c,
ScanCmd: cmd,
}
}
func (c *commandable) HScan(key string, cursor int64, match string, count int64) *ScanCmd {
func (c *commandable) HScan(key string, cursor int64, match string, count int64) Scanner {
args := []interface{}{"HSCAN", key, cursor}
if match != "" {
args = append(args, "MATCH", match)
@ -354,10 +360,13 @@ func (c *commandable) HScan(key string, cursor int64, match string, count int64)
}
cmd := NewScanCmd(args...)
c.Process(cmd)
return cmd
return Scanner{
client: c,
ScanCmd: cmd,
}
}
func (c *commandable) ZScan(key string, cursor int64, match string, count int64) *ScanCmd {
func (c *commandable) ZScan(key string, cursor int64, match string, count int64) Scanner {
args := []interface{}{"ZSCAN", key, cursor}
if match != "" {
args = append(args, "MATCH", match)
@ -367,7 +376,10 @@ func (c *commandable) ZScan(key string, cursor int64, match string, count int64)
}
cmd := NewScanCmd(args...)
c.Process(cmd)
return cmd
return Scanner{
client: c,
ScanCmd: cmd,
}
}
//------------------------------------------------------------------------------