学习redis的时候,随便整理下。接口:github.com/alphazero/Go-Redis 中的redis.client
1、AllKeys
无入参
出参:1、[]string 实例对应库中所有的Key值
2、redis.Error
返回对应库中所有的key(等于keys *)
2、Bgsave
入参:无
出参:redis.Error
后台保存rdb快照,执行后dump.rdb文件立即更新
3、Blpop
入参:keys string, timeout int
出参:1、[][]byte 弹出的结果
2、redis.Error
链表左边等待弹出key的尾/头元素,timeout为等待超时时间,如果timeout为0则一直等待下去
4、Brpop
入参:keys string, timeout int
出参:1、[][]byte 弹出的结果
2、redis.Error
链表右边等待弹出key的尾/头元素,timeout为等待超时时间,如果timeout为0则一直等待下去
5、Brpoplpush
入参:src string, desc string, timeout int
出参:1、[][]byte 弹出插入的结果
2、redis.Error
功能:从src链表右边弹出数据,在desc左边插入数据。在windows下测试发现功能ok,已经使redis完成对应功能,但是返回出错:SYSTEM_ERROR - ServiceRequest [cause: connHdl.ServiceRequest(BRPOPLPUSH) - failed to get response]测试的时候timeout已经设置为0了
6、Dbsize
入参:无
出参:result int64, redis.Error
功能:返回redis实例对应库中key的个数
7、Decr
入参:key string 对应string类型的key
出参:1、result int64 /*key值对应的value值减1后的结果*/
2、redis.Error
功能:实现对key对应的value值的原子减一操作。
8、Decrby
入参: key string 对应string类型的key, arg1 int64
出参:1、result int64 /*key值对应的value值减去arg1后的结果*/
2、redis.Error
功能:实现对key对应的value值的原子减对应值操作。
9、Del
入参:key string 想要删除的key
出参:1、rusult bool 删除是否成功
2、redis.Error
功能描述:删除的key
10、Exists
入参:key string 想要检查的key
出参:1、rusult bool 删除是否成功(功能:true,失败:false)
2、redis.Error
功能描述:检查key值是否存在。
11、Expire
入参: 1、key string 要进行设置的key值
2、arg1 int64 设置的生命周期 单位为秒
出参:1、rusult bool 是否设置成功(功能:true,失败:false)
2、redis.Error
功能描述:为key设置生命周期。
12、Flushall (谨用)
入参:无
出参:redis.Error
功能描述:删除所有数据库中的所有的key
13、Flushdb (谨用)
入参:无
出参:redis.Error
功能描述:删除当前库环境中的所有的key
14、Get
入参:key string 要获
1、AllKeys
无入参
出参:1、[]string 实例对应库中所有的Key值
2、redis.Error
返回对应库中所有的key(等于keys *)
2、Bgsave
入参:无
出参:redis.Error
后台保存rdb快照,执行后dump.rdb文件立即更新
3、Blpop
入参:keys string, timeout int
出参:1、[][]byte 弹出的结果
2、redis.Error
链表左边等待弹出key的尾/头元素,timeout为等待超时时间,如果timeout为0则一直等待下去
4、Brpop
入参:keys string, timeout int
出参:1、[][]byte 弹出的结果
2、redis.Error
链表右边等待弹出key的尾/头元素,timeout为等待超时时间,如果timeout为0则一直等待下去
5、Brpoplpush
入参:src string, desc string, timeout int
出参:1、[][]byte 弹出插入的结果
2、redis.Error
功能:从src链表右边弹出数据,在desc左边插入数据。在windows下测试发现功能ok,已经使redis完成对应功能,但是返回出错:SYSTEM_ERROR - ServiceRequest [cause: connHdl.ServiceRequest(BRPOPLPUSH) - failed to get response]测试的时候timeout已经设置为0了
6、Dbsize
入参:无
出参:result int64, redis.Error
功能:返回redis实例对应库中key的个数
7、Decr
入参:key string 对应string类型的key
出参:1、result int64 /*key值对应的value值减1后的结果*/
2、redis.Error
功能:实现对key对应的value值的原子减一操作。
8、Decrby
入参: key string 对应string类型的key, arg1 int64
出参:1、result int64 /*key值对应的value值减去arg1后的结果*/
2、redis.Error
功能:实现对key对应的value值的原子减对应值操作。
9、Del
入参:key string 想要删除的key
出参:1、rusult bool 删除是否成功
2、redis.Error
功能描述:删除的key
10、Exists
入参:key string 想要检查的key
出参:1、rusult bool 删除是否成功(功能:true,失败:false)
2、redis.Error
功能描述:检查key值是否存在。
11、Expire
入参: 1、key string 要进行设置的key值
2、arg1 int64 设置的生命周期 单位为秒
出参:1、rusult bool 是否设置成功(功能:true,失败:false)
2、redis.Error
功能描述:为key设置生命周期。
12、Flushall (谨用)
入参:无
出参:redis.Error
功能描述:删除所有数据库中的所有的key
13、Flushdb (谨用)
入参:无
出参:redis.Error
功能描述:删除当前库环境中的所有的key
14、Get
入参:key string 要获