Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRedis ¶
func NewRedis(conf BizRedisConf) *redisClient
Types ¶
type BasicCacher ¶
type BasicCacher interface { Prefix() string Has(key string) bool Get(key string, defaultValue ...interface{}) interface{} Pull(key string, defaultValue ...interface{}) interface{} Put(key string, value interface{}, future time.Time) bool Add(key string, value interface{}, future time.Time) bool Increment(key string, value int64) (incremented int64, success bool) Decrement(key string, value int64) (decremented int64, success bool) Forever(key string, value interface{}) bool Forget(key string) bool Close() error }
type BizRedisConf ¶
type Locker ¶
type Locker interface { Acquire() (bool, error) // Acquire acquires the lock. AcquireCtx(ctx context.Context) (bool, error) // AcquireCtx acquires the lock with the given ctx. Release() (bool, error) // Release releases the lock. ReleaseCtx(ctx context.Context) (bool, error) // ReleaseCtx releases the lock with the given ctx. SetExpire(seconds int) // SetExpire sets the expiration. }
type RedisClient ¶
type RedisClient interface { Client() *redis.Client BasicCacher RedisScripter }
type RedisLock ¶
type RedisLock struct {
// contains filtered or unexported fields
}
A RedisLock is a redis lock.
func NewRedisLock ¶
func NewRedisLock(store RedisScripter, key string) *RedisLock
NewRedisLock returns a RedisLock.
func (*RedisLock) AcquireCtx ¶
AcquireCtx acquires the lock with the given ctx.
func (*RedisLock) ReleaseCtx ¶
ReleaseCtx releases the lock with the given ctx.
type RedisScripter ¶
type RedisScripter interface { ScriptLoad(script string) (string, error) // ScriptLoad is the implementation of redis script load command. ScriptLoadCtx(ctx context.Context, script string) (string, error) // ScriptLoadCtx is the implementation of redis script load command. ScriptRun(script *Script, keys []string, args ...any) (any, error) // ScriptRun is the implementation of *redis.Script run command. ScriptRunCtx(ctx context.Context, script *Script, keys []string, args ...any) (val any, err error) // ScriptRunCtx is the implementation of *redis.Script run command. }
Click to show internal directories.
Click to hide internal directories.