1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package utils
- import (
- "eta/eta_api/utils/redis"
- "time"
- )
- type RedisClient interface {
- Get(key string) interface{}
- GetStr(key string) string
- GetUInt64(key string) (uint64, error)
- RedisBytes(key string) (data []byte, err error)
- RedisString(key string) (data string, err error)
- RedisInt(key string) (data int, err error)
- Put(key string, val interface{}, timeout time.Duration) error
- SetNX(key string, val interface{}, timeout time.Duration) bool
- Delete(key string) error
- IsExist(key string) bool
- LPush(key string, val interface{}) error
- Brpop(key string, callback func([]byte))
- GetRedisTTL(key string) time.Duration
- Incrby(key string, num int) (interface{}, error)
- Do(commandName string, args ...interface{}) (reply interface{}, err error)
- SAdd(key string, args ...interface{}) (err error)
- SRem(key string, args ...interface{}) (err error)
- SIsMember(key string, args interface{}) (bool, error)
- }
- func initRedis(redisType string, conf string) (redisClient RedisClient, err error) {
- switch redisType {
- case "cluster": // 集群
- redisClient, err = redis.InitClusterRedis(conf)
- default: // 默认走单机
- redisClient, err = redis.InitStandaloneRedis(conf)
- }
- return
- }
- // redis没有key的错误
- const RedisNoKeyErr = "redis: nil"
|