Documentation
¶
Index ¶
- Variables
- func IsRedisNil(err error) bool
- func MapStringToMapInterface(v map[string]string) map[string]interface{}
- func MapStringToMapRedisString(v map[string]string) map[string]RedisString
- type Caches
- type RedisClient
- func (client *RedisClient) Close() error
- func (client *RedisClient) Config() *RedisConfig
- func (client *RedisClient) Connect() error
- func (client *RedisClient) Copy() *RedisClient
- func (client *RedisClient) Counter(key string, args ...interface{}) *RedisCounter
- func (client *RedisClient) JSON(key string, args ...interface{}) *RedisJSON
- func (client *RedisClient) List(key string, args ...interface{}) *RedisList
- func (client *RedisClient) Locker(key string, args ...interface{}) *RedisLocker
- func (client *RedisClient) Marker(key string, args ...interface{}) *RedisMarker
- func (client *RedisClient) Name() string
- func (client *RedisClient) Ping() error
- func (client *RedisClient) Reconnect() error
- func (client *RedisClient) WithCtx(ctx context.Context) *RedisClient
- type RedisClientManager
- type RedisConfig
- type RedisConfigs
- type RedisCounter
- func (c *RedisCounter) Count() (int64, error)
- func (c *RedisCounter) Decr() error
- func (c *RedisCounter) DecrOfMarker(marker *RedisMarker) error
- func (c *RedisCounter) Destroy() error
- func (c *RedisCounter) Incr() error
- func (c *RedisCounter) IncrOfMarker(marker *RedisMarker) error
- func (c *RedisCounter) Key() string
- func (c *RedisCounter) Set(count int64, expiration time.Duration) error
- func (c *RedisCounter) Zero(expiration time.Duration) error
- type RedisJSON
- func (h *RedisJSON) Destroy() error
- func (j *RedisJSON) Exists() (bool, error)
- func (j *RedisJSON) Get(v interface{}) error
- func (j *RedisJSON) Key() string
- func (j *RedisJSON) Set(v interface{}, expiration time.Duration) error
- func (j *RedisJSON) SetNX(v interface{}, expiration time.Duration) error
- func (j *RedisJSON) SetXX(v interface{}, expiration time.Duration) error
- func (j *RedisJSON) TrySetNX(v interface{}, expiration time.Duration) (bool, error)
- func (j *RedisJSON) TrySetXX(v interface{}, expiration time.Duration) (bool, error)
- type RedisKey
- type RedisList
- type RedisLocker
- func (locker *RedisLocker) DoLock() (ok bool, err error)
- func (locker *RedisLocker) DoUnlock() (bool, error)
- func (locker *RedisLocker) GetExpiration() time.Duration
- func (locker *RedisLocker) GetRetries() int
- func (locker *RedisLocker) Key() string
- func (locker *RedisLocker) Lock() bool
- func (locker *RedisLocker) SetExpiration(expiration time.Duration) *RedisLocker
- func (locker *RedisLocker) SetInterval(interval time.Duration) *RedisLocker
- func (locker *RedisLocker) SetRetries(retries int) *RedisLocker
- func (locker *RedisLocker) Touch(duration time.Duration) error
- func (locker *RedisLocker) TouchAt(t time.Time) error
- func (locker *RedisLocker) Unlock() bool
- type RedisMarker
- func (marker *RedisMarker) Exist() (bool, error)
- func (marker *RedisMarker) Expire(duration time.Duration) error
- func (marker *RedisMarker) ExpireAt(t time.Time) error
- func (marker *RedisMarker) GetExpiration() time.Duration
- func (marker *RedisMarker) Key() string
- func (marker *RedisMarker) Mark() (bool, error)
- func (marker *RedisMarker) SetExpiration(expiration time.Duration) *RedisMarker
- func (marker *RedisMarker) Unmark() (bool, error)
- type RedisString
- func (s RedisString) Bool() bool
- func (s RedisString) Buffer() *bytes.Buffer
- func (s RedisString) Bytes() []byte
- func (s RedisString) Float32() float32
- func (s RedisString) Float64() float64
- func (s RedisString) Int() int
- func (s RedisString) Int16() int16
- func (s RedisString) Int32() int32
- func (s RedisString) Int64() int64
- func (s RedisString) Int8() int8
- func (s RedisString) IsEmpty() bool
- func (s RedisString) JSON(v interface{}) error
- func (s RedisString) ParseTime(layout string) time.Time
- func (s RedisString) Slice(sep string) []string
- func (s RedisString) String() string
- func (s RedisString) Time() time.Time
- func (s RedisString) TryBool() (bool, error)
- func (s RedisString) TryFloat32() (float32, error)
- func (s RedisString) TryFloat64() (float64, error)
- func (s RedisString) TryInt() (int, error)
- func (s RedisString) TryInt16() (int16, error)
- func (s RedisString) TryInt32() (int32, error)
- func (s RedisString) TryInt64() (int64, error)
- func (s RedisString) TryInt8() (int8, error)
- func (s RedisString) TryParseTime(layout string) (time.Time, error)
- func (s RedisString) TryTime() (time.Time, error)
- func (s RedisString) TryUint() (uint, error)
- func (s RedisString) TryUint16() (uint16, error)
- func (s RedisString) TryUint32() (uint32, error)
- func (s RedisString) TryUint64() (uint64, error)
- func (s RedisString) TryUint8() (uint8, error)
- func (s RedisString) Uint() uint
- func (s RedisString) Uint16() uint16
- func (s RedisString) Uint32() uint32
- func (s RedisString) Uint64() uint64
- func (s RedisString) Uint8() uint8
Constants ¶
This section is empty.
Variables ¶
var NotPtrErr = errors.New("input type is not a slice ptr")
var NotSliceErr = errors.New("input type is not a slice")
Functions ¶
func IsRedisNil ¶
func MapStringToMapInterface ¶
func MapStringToMapRedisString ¶
func MapStringToMapRedisString(v map[string]string) map[string]RedisString
Types ¶
type Caches ¶
type Caches struct {
// contains filtered or unexported fields
}
----------------------------------------
Redis 客户端管理器
----------------------------------------
func CreateCaches ¶
func CreateCaches() *Caches
func (*Caches) Redis ¶
func (caches *Caches) Redis(name string) *RedisClient
func (*Caches) RegisterRedisClient ¶
func (caches *Caches) RegisterRedisClient(name string, config *RedisConfig) error
func (*Caches) RegisterRedisClients ¶
func (caches *Caches) RegisterRedisClients(configs map[string]*RedisConfig) error
type RedisClient ¶
type RedisClient struct { *redis.Client // contains filtered or unexported fields }
----------------------------------------
Redis 客户端包装
----------------------------------------
func CreateRedisClient ¶
func CreateRedisClient(name string, config *RedisConfig) (*RedisClient, error)
func CreateRedisClientWithDriver ¶
func CreateRedisClientWithDriver(name string, driver *redis.Client) (*RedisClient, error)
func (*RedisClient) Close ¶
func (client *RedisClient) Close() error
func (*RedisClient) Config ¶
func (client *RedisClient) Config() *RedisConfig
func (*RedisClient) Connect ¶
func (client *RedisClient) Connect() error
func (*RedisClient) Copy ¶
func (client *RedisClient) Copy() *RedisClient
func (*RedisClient) Counter ¶
func (client *RedisClient) Counter(key string, args ...interface{}) *RedisCounter
func (*RedisClient) JSON ¶
func (client *RedisClient) JSON(key string, args ...interface{}) *RedisJSON
func (*RedisClient) List ¶
func (client *RedisClient) List(key string, args ...interface{}) *RedisList
func (*RedisClient) Locker ¶
func (client *RedisClient) Locker(key string, args ...interface{}) *RedisLocker
func (*RedisClient) Marker ¶
func (client *RedisClient) Marker(key string, args ...interface{}) *RedisMarker
func (*RedisClient) Name ¶
func (client *RedisClient) Name() string
func (*RedisClient) Ping ¶
func (client *RedisClient) Ping() error
func (*RedisClient) Reconnect ¶
func (client *RedisClient) Reconnect() error
func (*RedisClient) WithCtx ¶
func (client *RedisClient) WithCtx(ctx context.Context) *RedisClient
type RedisClientManager ¶
type RedisClientManager struct {
// contains filtered or unexported fields
}
----------------------------------------
Redis 客户端管理器
----------------------------------------
func CreateRedisClientManager ¶
func CreateRedisClientManager() *RedisClientManager
func (*RedisClientManager) Clear ¶
func (manager *RedisClientManager) Clear()
func (*RedisClientManager) Get ¶
func (manager *RedisClientManager) Get(name string) *RedisClient
func (*RedisClientManager) Set ¶
func (manager *RedisClientManager) Set(name string, client *RedisClient)
type RedisConfig ¶
type RedisConfig struct { Host string `toml:"host" mapstructure:"host"` Port int `toml:"port" mapstructure:"port"` Password string `toml:"password" mapstructure:"password"` Database int `toml:"database" mapstructure:"database"` MaxRetries int `toml:"max_retries" mapstructure:"max_retries"` PoolSize int `toml:"pool_size" mapstructure:"pool_size"` Ping bool `toml:"ping" mapstructure:"ping"` DialTimeout int `toml:"dial_timeout" mapstructure:"dial_timeout"` ReadTimeout int `toml:"read_timeout" mapstructure:"read_timeout"` WriteTimeout int `toml:"write_timeout" mapstructure:"write_timeout"` }
----------------------------------------
Redis 配置项(TOML 支持, Viper 支持)
----------------------------------------
func (*RedisConfig) Bind ¶
func (config *RedisConfig) Bind(bs []byte) error
type RedisConfigs ¶
type RedisConfigs struct {
Items map[string]*RedisConfig `toml:"redis"`
}
----------------------------------------
Redis 配置清单(TOML 支持)
----------------------------------------
type RedisCounter ¶
type RedisCounter struct {
// contains filtered or unexported fields
}
----------------------------------------
Redis 计数器
----------------------------------------
func CreateRedisCounter ¶
func CreateRedisCounter(client *RedisClient, key string, args ...interface{}) *RedisCounter
func (*RedisCounter) Count ¶
func (c *RedisCounter) Count() (int64, error)
func (*RedisCounter) Decr ¶
func (c *RedisCounter) Decr() error
func (*RedisCounter) DecrOfMarker ¶
func (c *RedisCounter) DecrOfMarker(marker *RedisMarker) error
func (*RedisCounter) Destroy ¶
func (c *RedisCounter) Destroy() error
func (*RedisCounter) Incr ¶
func (c *RedisCounter) Incr() error
func (*RedisCounter) IncrOfMarker ¶
func (c *RedisCounter) IncrOfMarker(marker *RedisMarker) error
func (*RedisCounter) Key ¶
func (c *RedisCounter) Key() string
type RedisJSON ¶
type RedisJSON struct {
// contains filtered or unexported fields
}
----------------------------------------
Redis JSON 数据
----------------------------------------
func CreateRedisJSON ¶
func CreateRedisJSON(client *RedisClient, key string, args ...interface{}) *RedisJSON
type RedisKey ¶
type RedisKey string
----------------------------------------
Redis 键
----------------------------------------
type RedisList ¶
type RedisList struct {
// contains filtered or unexported fields
}
----------------------------------------
Redis List
----------------------------------------
func CreateRedisList ¶
func CreateRedisList(client *RedisClient, key string, args ...interface{}) *RedisList
type RedisLocker ¶
type RedisLocker struct {
// contains filtered or unexported fields
}
----------------------------------------
Redis 锁
----------------------------------------
func CreateRedisLocker ¶
func CreateRedisLocker(client *RedisClient, key string, args ...interface{}) *RedisLocker
func (*RedisLocker) DoLock ¶
func (locker *RedisLocker) DoLock() (ok bool, err error)
func (*RedisLocker) DoUnlock ¶
func (locker *RedisLocker) DoUnlock() (bool, error)
func (*RedisLocker) GetExpiration ¶
func (locker *RedisLocker) GetExpiration() time.Duration
func (*RedisLocker) GetRetries ¶
func (locker *RedisLocker) GetRetries() int
func (*RedisLocker) Key ¶
func (locker *RedisLocker) Key() string
func (*RedisLocker) Lock ¶
func (locker *RedisLocker) Lock() bool
func (*RedisLocker) SetExpiration ¶
func (locker *RedisLocker) SetExpiration(expiration time.Duration) *RedisLocker
func (*RedisLocker) SetInterval ¶
func (locker *RedisLocker) SetInterval(interval time.Duration) *RedisLocker
func (*RedisLocker) SetRetries ¶
func (locker *RedisLocker) SetRetries(retries int) *RedisLocker
func (*RedisLocker) Unlock ¶
func (locker *RedisLocker) Unlock() bool
type RedisMarker ¶
type RedisMarker struct {
// contains filtered or unexported fields
}
func CreateRedisMarker ¶
func CreateRedisMarker(client *RedisClient, key string, args ...interface{}) *RedisMarker
func (*RedisMarker) Exist ¶
func (marker *RedisMarker) Exist() (bool, error)
func (*RedisMarker) GetExpiration ¶
func (marker *RedisMarker) GetExpiration() time.Duration
func (*RedisMarker) Key ¶
func (marker *RedisMarker) Key() string
func (*RedisMarker) Mark ¶
func (marker *RedisMarker) Mark() (bool, error)
func (*RedisMarker) SetExpiration ¶
func (marker *RedisMarker) SetExpiration(expiration time.Duration) *RedisMarker
func (*RedisMarker) Unmark ¶
func (marker *RedisMarker) Unmark() (bool, error)
type RedisString ¶
type RedisString string
----------------------------------------
Redis 字符串
----------------------------------------
func (RedisString) Bool ¶
func (s RedisString) Bool() bool
func (RedisString) Buffer ¶
func (s RedisString) Buffer() *bytes.Buffer
func (RedisString) Bytes ¶
func (s RedisString) Bytes() []byte
func (RedisString) Float32 ¶
func (s RedisString) Float32() float32
func (RedisString) Float64 ¶
func (s RedisString) Float64() float64
func (RedisString) Int ¶
func (s RedisString) Int() int
func (RedisString) Int16 ¶
func (s RedisString) Int16() int16
func (RedisString) Int32 ¶
func (s RedisString) Int32() int32
func (RedisString) Int64 ¶
func (s RedisString) Int64() int64
func (RedisString) Int8 ¶
func (s RedisString) Int8() int8
func (RedisString) IsEmpty ¶
func (s RedisString) IsEmpty() bool
func (RedisString) JSON ¶
func (s RedisString) JSON(v interface{}) error
func (RedisString) Slice ¶
func (s RedisString) Slice(sep string) []string
func (RedisString) String ¶
func (s RedisString) String() string
func (RedisString) Time ¶
func (s RedisString) Time() time.Time
func (RedisString) TryBool ¶
func (s RedisString) TryBool() (bool, error)
func (RedisString) TryFloat32 ¶
func (s RedisString) TryFloat32() (float32, error)
func (RedisString) TryFloat64 ¶
func (s RedisString) TryFloat64() (float64, error)
func (RedisString) TryInt ¶
func (s RedisString) TryInt() (int, error)
func (RedisString) TryInt16 ¶
func (s RedisString) TryInt16() (int16, error)
func (RedisString) TryInt32 ¶
func (s RedisString) TryInt32() (int32, error)
func (RedisString) TryInt64 ¶
func (s RedisString) TryInt64() (int64, error)
func (RedisString) TryInt8 ¶
func (s RedisString) TryInt8() (int8, error)
func (RedisString) TryParseTime ¶
func (s RedisString) TryParseTime(layout string) (time.Time, error)
func (RedisString) TryUint ¶
func (s RedisString) TryUint() (uint, error)
func (RedisString) TryUint16 ¶
func (s RedisString) TryUint16() (uint16, error)
func (RedisString) TryUint32 ¶
func (s RedisString) TryUint32() (uint32, error)
func (RedisString) TryUint64 ¶
func (s RedisString) TryUint64() (uint64, error)
func (RedisString) TryUint8 ¶
func (s RedisString) TryUint8() (uint8, error)
func (RedisString) Uint ¶
func (s RedisString) Uint() uint
func (RedisString) Uint16 ¶
func (s RedisString) Uint16() uint16
func (RedisString) Uint32 ¶
func (s RedisString) Uint32() uint32
func (RedisString) Uint64 ¶
func (s RedisString) Uint64() uint64
func (RedisString) Uint8 ¶
func (s RedisString) Uint8() uint8