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

Support SCAN and friends.

This commit is contained in:
Vladimir Mihailenco
2014-01-09 10:17:38 +02:00
parent 4252b31cd9
commit 62e78627c1
4 changed files with 416 additions and 129 deletions

View File

@@ -229,18 +229,57 @@ func (c *Client) Type(key string) *StatusCmd {
return req
}
// func (c *Client) Scan(cursor, match string, count int64) *ScanCmd {
// args := []string{"SCAN", cursor}
// if match != "" {
// args = append(args, "MATCH", match)
// }
// if count > 0 {
// args = append(args, "COUNT", strconv.FormatInt(count, 10))
// }
// req := NewScanCmd(args...)
// c.Process(req)
// return req
// }
func (c *Client) Scan(cursor int64, match string, count int64) *ScanCmd {
args := []string{"SCAN", strconv.FormatInt(cursor, 10)}
if match != "" {
args = append(args, "MATCH", match)
}
if count > 0 {
args = append(args, "COUNT", strconv.FormatInt(count, 10))
}
req := NewScanCmd(args...)
c.Process(req)
return req
}
func (c *Client) SScan(key string, cursor int64, match string, count int64) *ScanCmd {
args := []string{"SSCAN", key, strconv.FormatInt(cursor, 10)}
if match != "" {
args = append(args, "MATCH", match)
}
if count > 0 {
args = append(args, "COUNT", strconv.FormatInt(count, 10))
}
req := NewScanCmd(args...)
c.Process(req)
return req
}
func (c *Client) HScan(key string, cursor int64, match string, count int64) *ScanCmd {
args := []string{"HSCAN", key, strconv.FormatInt(cursor, 10)}
if match != "" {
args = append(args, "MATCH", match)
}
if count > 0 {
args = append(args, "COUNT", strconv.FormatInt(count, 10))
}
req := NewScanCmd(args...)
c.Process(req)
return req
}
func (c *Client) ZScan(key string, cursor int64, match string, count int64) *ScanCmd {
args := []string{"ZSCAN", key, strconv.FormatInt(cursor, 10)}
if match != "" {
args = append(args, "MATCH", match)
}
if count > 0 {
args = append(args, "COUNT", strconv.FormatInt(count, 10))
}
req := NewScanCmd(args...)
c.Process(req)
return req
}
//------------------------------------------------------------------------------