cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2020 License: MIT Imports: 7 Imported by: 17

Documentation

Index

Constants

View Source
const (
	CacheKey       = "Key.CacheKey"
	RedisLockerKey = "Key.RedisLockerKey"
)
View Source
const (
	DefaultLockTTL = 30 * time.Second

	MinimumLockTTL = 100 * time.Millisecond
	MaximumLockTTL = 5 * time.Minute
)
View Source
const (
	DefaultNonceExpire = time.Duration(3 * time.Minute)
)

Variables

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

Functions

func ExecuteSingleCall added in v0.0.5

func ExecuteSingleCall(ctx context.Context, name string, call SingleCall) error

func InitSingleCall added in v0.0.5

func InitSingleCall(ctx context.Context, name string) error

func Nonce added in v0.0.5

func Nonce(ctx context.Context, name string, nonce uint64) (uint64, error)

func OptionArgs

func OptionArgs(args *RedisOptions)

func RedisMutexContext added in v0.0.3

func RedisMutexContext(ctx context.Context) context.Context

func ResetNonce added in v0.0.5

func ResetNonce(ctx context.Context, name string) error

func ToRedis

func ToRedis(cache Cache) *redis.Client

func WithCache added in v0.1.0

func WithCache(ctx context.Context, cache Cache) context.Context

WithCache returns a context with the messaging set

Types

type Cache added in v0.1.0

type Cache interface {
	RDB() RDB
}

func FromContext added in v0.1.0

func FromContext(ctx context.Context) Cache

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 LockBatchNetwork added in v0.0.5

func LockBatchNetwork(ctx context.Context, batchNetwork string) (Lock, error)

func LockChain added in v0.0.3

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

func LockGeneric added in v0.0.5

func LockGeneric(ctx context.Context, name 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 RDB added in v0.1.0

type RDB interface{}

Cache (Redis)

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() 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 {
	HostName string
	Port     int
}

type SingleCall added in v0.0.5

type SingleCall func(ctx context.Context) error

Jump to

Keyboard shortcuts

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