Documentation ¶
Index ¶
- Constants
- Variables
- func AddOptionParser(adapter string, parser func(cache.Options) (cache.Options, error))
- func AdminRefreshable(ctx echo.Context, customer *dbschema.OfficialCustomer, ttl x.GetOption) x.GetOption
- func Cache(ctx context.Context, args ...string) cache.Cache
- func CacheNew(ctx context.Context, opts cache.Options, keys ...string) error
- func CloseCache()
- func Decr(ctx context.Context, key string, args ...string) error
- func DefaultLockType() int32
- func Delete(ctx context.Context, key string, args ...string) error
- func Flush(ctx context.Context, args ...string) error
- func GenOptions(ctx echo.Context, cacheSeconds int64) []x.GetOption
- func Get(ctx context.Context, key string, recv interface{}, args ...string) error
- func Incr(ctx context.Context, key string, args ...string) error
- func IsDbAccount(v string) bool
- func IsExist(ctx context.Context, key string, args ...string) (bool, error)
- func NewDBCacher() factory.Cacher
- func Put(ctx context.Context, key string, val interface{}, timeout int64, ...) error
- func RedisClient() *redis.Client
- func RedisMutex(key string, options ...redsync.Option) *redsync.Mutex
- func RedisOptions() *redis.Options
- func RedsyncClient() *redsync.Redsync
- func RegisterTryLocker(t int32, fn TryLocker)
- func SetDefaultLockType(lockType int32)
- func TTLIf(condition bool, a x.GetOption, b x.GetOption) x.GetOption
- func TTLIfCallback(condition func() bool, a x.GetOption, b x.GetOption) x.GetOption
- func XFunc(ctx context.Context, key string, recv interface{}, fn func() error, ...) error
- func XQuery(ctx context.Context, key string, recv interface{}, query x.Querier, ...) error
- type QueryFunc
- type TryLocker
- type UnlockFunc
- func Lock(key string, types ...int32) (unlock UnlockFunc, err error)
- func TryLock(key string, types ...int32) (unlock UnlockFunc, err error)
- func TryLockWithContext(key string, ctx context.Context, types ...int32) (unlock UnlockFunc, err error)
- func TryLockWithTimeout(key string, timeout time.Duration, types ...int32) (unlock UnlockFunc, err error)
Constants ¶
View Source
const ( Disabled = x.Disabled Fresh = x.Fresh )
View Source
const ( LockTypeMemory int32 = iota LockTypeRedis )
Variables ¶
View Source
var ( TTL = x.TTL TTLFresh = TTL(x.Fresh) TTLDisabled = TTL(x.Disabled) Query = x.Query DisableCacheUsage = x.DisableCacheUsage UseFreshData = x.UseFreshData )
View Source
var DBCacher = NewDBCacher()
View Source
var ErrFailedToAcquireLock = errors.New("failed to acquire lock")
Functions ¶
func AddOptionParser ¶
func AdminRefreshable ¶
func CloseCache ¶ added in v0.0.2
func CloseCache()
func DefaultLockType ¶
func DefaultLockType() int32
func IsDbAccount ¶
func NewDBCacher ¶
func RedisClient ¶
func RedisClient() *redis.Client
func RedisMutex ¶
func RedisMutex(key string, options ...redsync.Option) *redsync.Mutex
RedisMutex 分布式锁 example: mutex := RedisMutex(`goods_1`) err = mutex.Lock(ctx)
if err != nil { panic(err) }
mutex.Unlock(ctx)
func RedisOptions ¶
func RedisOptions() *redis.Options
func RedsyncClient ¶
func RedsyncClient() *redsync.Redsync
func RegisterTryLocker ¶
func SetDefaultLockType ¶
func SetDefaultLockType(lockType int32)
func TTLIfCallback ¶ added in v0.1.9
Types ¶
type TryLocker ¶
type TryLocker interface { Lock(key string) (unlock UnlockFunc, err error) TryLock(key string) (unlock UnlockFunc, err error) TryLockWithTimeout(key string, timeout time.Duration) (unlock UnlockFunc, err error) TryLockWithContext(key string, ctx context.Context) (unlock UnlockFunc, err error) }
Click to show internal directories.
Click to hide internal directories.