godis

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(conn redis.Conn, key string) ([]byte, error)

func Ping

func Ping(pool *redis.Pool) (err error)

func Read

func Read(conn redis.Conn, key string, bean interface{}) error

func ReadFromJSON

func ReadFromJSON(conn redis.Conn, key string, bean interface{}) error

func Write

func Write(conn redis.Conn, key string, bean interface{}, expiry time.Duration) error

func WriteToJSON

func WriteToJSON(conn redis.Conn, key string, bean interface{}, expiry time.Duration) error

Types

type Locker

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

func NewLocker

func NewLocker(conn redis.Conn, key string, options ...Option) *Locker

func (*Locker) Lock

func (lk *Locker) Lock() (bool, error)

func (*Locker) Unlock

func (lk *Locker) Unlock() error

type Option

type Option interface {
	// contains filtered or unexported methods
}

func SetExpiry

func SetExpiry(expiry time.Duration) Option

func SetName

func SetName(name string) Option

func SetRetryDelay

func SetRetryDelay(delay time.Duration) Option

func SetToken

func SetToken(token string) Option

func SetTries

func SetTries(tries int) Option

type RedisPool

type RedisPool struct {
	Pool   *redis.Pool
	Ping   func() error
	Locker func(conn redis.Conn, key string, expiry time.Duration, tries int, retryDelay time.Duration) *Locker
}

func NewRedisPool

func NewRedisPool(addr string, maxIdle, maxActive int, password, db string) *RedisPool

Jump to

Keyboard shortcuts

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