123456789101112131415161718192021222324252627282930313233343536 |
- package utils
- import (
- "context"
- "eta/eta_mini_crm_ht/utils/redis"
- "time"
- )
- type RedisClient interface {
- Get(key string) interface{}
- 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
- SetEX(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)
- RunLUA(command string, ctx context.Context, keys []string, args ...interface{}) bool
- }
- 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
- }
|