Documentation
¶
Index ¶
- Constants
- Variables
- func CacheProviderNeedKeyError() gone.Error
- func KeyNoExpirationError() gone.Error
- func NewCacheProvider() (gone.Vampire, gone.GonerId)
- func NewInner() (gone.Goner, gone.GonerId)
- func NewRedisCache() (gone.Goner, gone.GonerId)
- func NewRedisLocker() (gone.Goner, gone.GonerId)
- func NewRedisPool() (gone.Angel, gone.GonerId)
- func Priest(cemetery gone.Cemetery) error
- type Cache
- type Conn
- type Hash
- type Key
- type Locker
- type Pool
- type Unlock
Constants ¶
View Source
const ( //CacheProviderNeedKey cache provider need a key CacheProviderNeedKey = 1501 + iota KeyNoExpiration )
View Source
const IdGoneRedisInner = "gone-redis-inner"
Variables ¶
View Source
var ( ErrNil = redis.ErrNil ErrNotExpire = KeyNoExpirationError() Int = redis.Int Int64 = redis.Int64 Uint64 = redis.Uint64 Float64 = redis.Float64 String = redis.String Bytes = redis.Bytes Bool = redis.Bool Values = redis.Values Float64s = redis.Float64s Strings = redis.Strings ByteSlices = redis.ByteSlices Int64s = redis.Int64s Ints = redis.Ints StringMap = redis.StringMap IntMap = redis.IntMap Int64Map = redis.Int64Map Float64Map = redis.Float64Map Positions = redis.Positions Uint64s = redis.Uint64s Uint64Map = redis.Uint64Map SlowLogs = redis.SlowLogs Latencies = redis.Latencies LatencyHistories = redis.LatencyHistories )
View Source
var ErrorLockFailed = errors.New("not lock success")
Functions ¶
func CacheProviderNeedKeyError ¶ added in v0.0.21
func KeyNoExpirationError ¶ added in v0.0.21
Types ¶
type Cache ¶
type Cache interface {
Put(key string, value any, ttl ...time.Duration) error
Set(key string, value any, ttl ...time.Duration) error
Get(key string, value any) error
Remove(key string) (err error)
Keys(key string) ([]string, error)
//Prefix get key prefix in redis
Prefix() string
}
Cache redis cache, which use redis string to store value(encoded to json) HOW TO USE
type GoneComponent struct {
redis.Cache `gone:"gone-redis-cache"`
}
func (c *GoneComponent) useRedisCache(){
key := "test"
value := map[string]interface{}{
"some": "string"
}
c.Put(key, value) //store value to redis key
c.Get(key, &value)//fetch value from redis
}
Click to show internal directories.
Click to hide internal directories.