Documentation
¶
Overview ¶
Package cache 缓存工具类,可以缓存各种类型包括 struct 对象
Package wtredis 工具包
Index ¶
- func ConnectRedis()
- func ConnectRedisCache()
- func Decrement(parameters ...interface{})
- func Delete(key string) bool
- func Exist(key ...string) bool
- func Flush()
- func Forever(key string, value string)
- func Forget(key string)
- func Get(key string) interface{}
- func GetToBool(key string) bool
- func GetToDuration(key string) time.Duration
- func GetToFloat64(key string) float64
- func GetToInt(key string) int
- func GetToInt32(key string) int32
- func GetToInt64(key string) int64
- func GetToIntSlice(key string) []int
- func GetToObject(key string, wanted interface{})
- func GetToString(key string) string
- func GetToStringMap(key string) map[string]interface{}
- func GetToStringMapString(key string) map[string]string
- func GetToStringMapStringSlice(key string) map[string][]string
- func GetToStringSlice(key string) []string
- func GetToTime(key string) time.Time
- func GetToUint(key string) uint
- func GetToUint32(key string) uint32
- func GetToUint64(key string) uint64
- func Has(key string) bool
- func Increment(parameters ...interface{})
- func IsAlive() error
- func IsRedisNilErr(err error) bool
- func PreDelAll(pre string) error
- func Set(key string, obj interface{}, expireTime time.Duration)
- func SetString(key string, val string, expireTime time.Duration)
- type CacheService
- type RedisClient
- func (rds RedisClient) Decrement(parameters ...interface{}) bool
- func (rds RedisClient) Del(keys ...string) bool
- func (rds RedisClient) Exist(key ...string) bool
- func (rds RedisClient) FlushDB() bool
- func (rds RedisClient) Get(key string) string
- func (rds RedisClient) GetInBy(key string) string
- func (rds RedisClient) GetToObject(key string, wanted interface{})
- func (rds RedisClient) Has(key string) bool
- func (rds RedisClient) Increment(parameters ...interface{}) bool
- func (rds RedisClient) LockLucky(key string) bool
- func (rds RedisClient) MGet(keys ...string) (result []interface{})
- func (rds RedisClient) MSet(keyValue map[string]interface{}) bool
- func (rds RedisClient) MSetObj(keyValue map[string]interface{}) bool
- func (rds RedisClient) Ping() error
- func (rds RedisClient) Set(key string, value interface{}, expiration time.Duration) bool
- func (rds RedisClient) SetExpiration(key string, expiration time.Duration) bool
- func (rds RedisClient) SetObj(key string, obj interface{}, expireTime time.Duration)
- func (rds RedisClient) UnLockLucky(key string) bool
- type RedisStore
- func (s *RedisStore) Decrement(parameters ...interface{})
- func (s *RedisStore) Delete(key string) bool
- func (s *RedisStore) Exist(key ...string) bool
- func (s *RedisStore) Flush()
- func (s *RedisStore) Forever(key string, value string)
- func (s *RedisStore) Forget(key string)
- func (s *RedisStore) Get(key string) string
- func (s *RedisStore) Has(key string) bool
- func (s *RedisStore) Increment(parameters ...interface{})
- func (s *RedisStore) IsAlive() error
- func (s *RedisStore) PreDelAll(pre string) error
- func (s *RedisStore) Set(key string, value string, expireTime time.Duration)
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectRedisCache ¶ added in v1.0.1
func ConnectRedisCache()
func GetToDuration ¶
func GetToFloat64 ¶
func GetToInt32 ¶
func GetToInt64 ¶
func GetToIntSlice ¶
func GetToObject ¶
func GetToObject(key string, wanted interface{})
GetToObject 应该传地址,用法如下:
model := user.User{} cache.GetObject("key", &model)
func GetToString ¶
func GetToStringMap ¶
func GetToStringMapString ¶
func GetToStringSlice ¶
func GetToUint32 ¶
func GetToUint64 ¶
func IsRedisNilErr ¶
Types ¶
type RedisClient ¶
RedisClient Redis 服务
var Redis *RedisClient
Redis 全局 Redis,使用 db 1
func NewCacheClient ¶ added in v1.0.1
func NewCacheClient() *RedisClient
NewCacheClient 创建一个新的 redis 连接
func (RedisClient) Decrement ¶
func (rds RedisClient) Decrement(parameters ...interface{}) bool
Decrement 当参数只有 1 个时,为 key,其值减去 1。 当参数有 2 个时,第一个参数为 key ,第二个参数为要减去的值 int64 类型。
func (RedisClient) Del ¶
func (rds RedisClient) Del(keys ...string) bool
Del 删除存储在 redis 里的数据,支持多个 key 传参
func (RedisClient) Exist ¶
func (rds RedisClient) Exist(key ...string) bool
func (RedisClient) GetInBy ¶
func (rds RedisClient) GetInBy(key string) string
func (RedisClient) GetToObject ¶
func (rds RedisClient) GetToObject(key string, wanted interface{})
func (RedisClient) Has ¶
func (rds RedisClient) Has(key string) bool
Has 判断一个 key 是否存在,内部错误和 redis.Nil 都返回 false
func (RedisClient) Increment ¶
func (rds RedisClient) Increment(parameters ...interface{}) bool
Increment 当参数只有 1 个时,为 key,其值增加 1。 当参数有 2 个时,第一个参数为 key ,第二个参数为要增加的值 int64 类型。
func (RedisClient) LockLucky ¶
func (rds RedisClient) LockLucky(key string) bool
func (RedisClient) MGet ¶
func (rds RedisClient) MGet(keys ...string) (result []interface{})
MGet 获取 key 对应的 value
func (RedisClient) MSet ¶
func (rds RedisClient) MSet(keyValue map[string]interface{}) bool
func (RedisClient) MSetObj ¶
func (rds RedisClient) MSetObj(keyValue map[string]interface{}) bool
func (RedisClient) Set ¶
func (rds RedisClient) Set(key string, value interface{}, expiration time.Duration) bool
Set 存储 key 对应的 value,且设置 expiration 过期时间
func (RedisClient) SetExpiration ¶
func (rds RedisClient) SetExpiration(key string, expiration time.Duration) bool
SetExpiration 设置 key 对应的 过期时间,且设置 expiration 过期时间
func (RedisClient) SetObj ¶
func (rds RedisClient) SetObj(key string, obj interface{}, expireTime time.Duration)
func (RedisClient) UnLockLucky ¶
func (rds RedisClient) UnLockLucky(key string) bool
type RedisStore ¶
type RedisStore struct { RedisClient *RedisClient KeyPrefix string }
RedisStore 实现 cache.Store interface
func (*RedisStore) Decrement ¶
func (s *RedisStore) Decrement(parameters ...interface{})
func (*RedisStore) Delete ¶
func (s *RedisStore) Delete(key string) bool
func (*RedisStore) Exist ¶
func (s *RedisStore) Exist(key ...string) bool
func (*RedisStore) Flush ¶
func (s *RedisStore) Flush()
func (*RedisStore) Forever ¶
func (s *RedisStore) Forever(key string, value string)
func (*RedisStore) Forget ¶
func (s *RedisStore) Forget(key string)
func (*RedisStore) Get ¶
func (s *RedisStore) Get(key string) string
func (*RedisStore) Has ¶
func (s *RedisStore) Has(key string) bool
func (*RedisStore) Increment ¶
func (s *RedisStore) Increment(parameters ...interface{})
func (*RedisStore) IsAlive ¶
func (s *RedisStore) IsAlive() error
func (*RedisStore) PreDelAll ¶
func (s *RedisStore) PreDelAll(pre string) error
type Store ¶
type Store interface { Set(key string, value string, expireTime time.Duration) Get(key string) string Has(key string) bool Delete(key string) bool Forget(key string) Forever(key string, value string) Flush() PreDelAll(pre string) error IsAlive() error // Increment 当参数只有 1 个时,为 key,增加 1。 // 当参数有 2 个时,第一个参数为 key ,第二个参数为要增加的值 int64 类型。 Increment(parameters ...interface{}) // Decrement 当参数只有 1 个时,为 key,减去 1。 // 当参数有 2 个时,第一个参数为 key ,第二个参数为要减去的值 int64 类型。 Decrement(parameters ...interface{}) Exist(key ...string) bool }
Click to show internal directories.
Click to hide internal directories.