mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
添加redis scan方法
This commit is contained in:
@@ -73,8 +73,9 @@ func (slf *GateService) Test(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (slf *GateService) TestRedis() {
|
func (slf *GateService) TestRedis() {
|
||||||
slf.redisModule.GetHashValueByHashKeyList("BITGET_2160_LastSetLevelInfo", "SBTC_USD_1", "BTC_SUSDT_1", "SBTC_USD_3")
|
//slf.redisModule.GetHashValueByHashKeyList("BITGET_2160_LastSetLevelInfo", "SBTC_USD_1", "BTC_SUSDT_1", "SBTC_USD_3")
|
||||||
//slf.redisModule.GetHashValueByKey("BITGET_2160_LastSetLevelInfo", "SBTC_USD_1")
|
//slf.redisModule.GetHashValueByKey("BITGET_2160_LastSetLevelInfo", "SBTC_USD_1")
|
||||||
|
slf.redisModule.ScanMatchKeys(192, "ZC*", 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (slf *GateService) HttpTest(session *sysservice.HttpSession) {
|
func (slf *GateService) HttpTest(session *sysservice.HttpSession) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/duanhf2012/origin/log"
|
"github.com/duanhf2012/origin/log"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/duanhf2012/origin/service"
|
"github.com/duanhf2012/origin/service"
|
||||||
@@ -760,21 +761,38 @@ func (slf *RedisModule) GetHashValueByHashKeyList(fieldKey ...interface{}) ([]st
|
|||||||
return retList, nil
|
return retList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/*func (slf *RedisModule) ScanMatchKeys(cursorValue int, redisKey string, count int) ([]string, error) {
|
func (slf *RedisModule) ScanMatchKeys(cursorValue int, redisKey string, count int) (int, []string, error) {
|
||||||
retKeys := []string{}
|
retKeys := []string{}
|
||||||
|
nextCursorValue := 0
|
||||||
if redisKey == "" {
|
if redisKey == "" {
|
||||||
log.Error("ScanMatchKeys key is empty!")
|
log.Error("ScanMatchKeys key is empty!")
|
||||||
return nil, errors.New("Key Is Empty")
|
return nextCursorValue, nil, errors.New("Key Is Empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := slf.getConn()
|
conn, err := slf.getConn()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nextCursorValue, nil, err
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
return retKeys, nil
|
value, err := conn.Do("SCAN", cursorValue, "match", redisKey, "count", count)
|
||||||
}*/
|
if err != nil {
|
||||||
|
log.Error("GetHashValueByKey fail,reason:%v", err)
|
||||||
|
return nextCursorValue, nil, err
|
||||||
|
}
|
||||||
|
if value == nil {
|
||||||
|
return nextCursorValue, nil, errors.New("Reids Get Hash nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
valueList := value.([]interface{})
|
||||||
|
nextCursorValue, _ = strconv.Atoi(string(valueList[0].([]byte)))
|
||||||
|
keysList := valueList[1].([]interface{})
|
||||||
|
for _, keysItem := range keysList {
|
||||||
|
retKeys = append(retKeys, string(keysItem.([]byte)))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nextCursorValue, retKeys, nil
|
||||||
|
}
|
||||||
|
|
||||||
//SetRedisHashJSON ...
|
//SetRedisHashJSON ...
|
||||||
func (slf *RedisModule) SetHashJSON(redisKey, hsahKey string, value interface{}) error {
|
func (slf *RedisModule) SetHashJSON(redisKey, hsahKey string, value interface{}) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user