cache

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2020 License: MIT Imports: 9 Imported by: 17

Documentation

Index

Constants

View Source
const (
	DefaultLockTTL = 30 * time.Second

	MinimumLockTTL = 100 * time.Millisecond
	MaximumLockTTL = 5 * time.Minute
)
View Source
const (
	RedisLockerKey = "Key.RedisLockerKey"
)

Variables

View Source
var (
	ErrRedisMutexNotFound = errors.New("RedisMutex Not Found")
	ErrLockError          = errors.New("Failed to acquire lock")
)
View Source
var (
	ErrInternalError = errors.New("InternalError")
)

Functions

func OptionArgs

func OptionArgs(args *RedisOptions)

func RedisMutexContext added in v0.0.3

func RedisMutexContext(ctx context.Context) context.Context

func ToRedis

func ToRedis(cache bank.Cache) *redis.Client

Types

type Lock added in v0.0.3

type Lock interface {
	Unlock()
}

func LockAccount added in v0.0.3

func LockAccount(ctx context.Context, accountID uint64) (Lock, error)

func LockChain added in v0.0.3

func LockChain(ctx context.Context, chain string) (Lock, error)

func LockUser added in v0.0.3

func LockUser(ctx context.Context, userID uint64) (Lock, error)

type Mutex added in v0.0.3

type Mutex interface {
	Lock(ctx context.Context, key string, ttl time.Duration) (Lock, error)
}

func NewRedisMutex added in v0.0.3

func NewRedisMutex(ctx context.Context) Mutex

func RedisMutexFromContext added in v0.0.3

func RedisMutexFromContext(ctx context.Context) Mutex

type Redis

type Redis struct {
	// contains filtered or unexported fields
}

func NewRedis

func NewRedis(ctx context.Context, options RedisOptions) *Redis

func (*Redis) RDB

func (r *Redis) RDB() bank.RDB

type RedisLock added in v0.0.3

type RedisLock struct {
	// contains filtered or unexported fields
}

func (*RedisLock) Unlock added in v0.0.3

func (p *RedisLock) Unlock()

type RedisMutex added in v0.0.3

type RedisMutex struct {
	// contains filtered or unexported fields
}

func (*RedisMutex) Lock added in v0.0.3

func (p *RedisMutex) Lock(ctx context.Context, key string, ttl time.Duration) (Lock, error)

type RedisOptions

type RedisOptions struct {
	bank.ServerOptions
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL