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

add new command Touch and SwapDB

This commit is contained in:
Huan Du
2018-02-14 12:42:19 +08:00
committed by Vladimir Mihailenco
parent 32f020f1fa
commit daab7c60d0
2 changed files with 43 additions and 0 deletions

View File

@ -73,6 +73,7 @@ type Cmdable interface {
Sort(key string, sort *Sort) *StringSliceCmd
SortStore(key, store string, sort *Sort) *IntCmd
SortInterfaces(key string, sort *Sort) *SliceCmd
Touch(keys ...string) *IntCmd
TTL(key string) *DurationCmd
Type(key string) *StatusCmd
Scan(cursor uint64, match string, count int64) *ScanCmd
@ -253,6 +254,7 @@ type StatefulCmdable interface {
Cmdable
Auth(password string) *StatusCmd
Select(index int) *StatusCmd
SwapDB(index1, index2 int) *StatusCmd
ClientSetName(name string) *BoolCmd
ReadOnly() *StatusCmd
ReadWrite() *StatusCmd
@ -317,6 +319,12 @@ func (c *statefulCmdable) Select(index int) *StatusCmd {
return cmd
}
func (c *statefulCmdable) SwapDB(index1, index2 int) *StatusCmd {
cmd := NewStatusCmd("swapdb", index1, index2)
c.process(cmd)
return cmd
}
//------------------------------------------------------------------------------
func (c *cmdable) Del(keys ...string) *IntCmd {
@ -533,6 +541,17 @@ func (c *cmdable) SortInterfaces(key string, sort *Sort) *SliceCmd {
return cmd
}
func (c *cmdable) Touch(keys ...string) *IntCmd {
args := make([]interface{}, len(keys)+1)
args[0] = "touch"
for i, key := range keys {
args[i+1] = key
}
cmd := NewIntCmd(args...)
c.process(cmd)
return cmd
}
func (c *cmdable) TTL(key string) *DurationCmd {
cmd := NewDurationCmd(time.Second, "ttl", key)
c.process(cmd)