cache

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const LockKeyPrefix = "gold.lock"
View Source
const RetryTime = 5
View Source
const TimeOut = 100 * time.Millisecond

Variables

This section is empty.

Functions

func Marshal

func Marshal(value interface{}) ([]byte, error)

func UnMarshal

func UnMarshal(data []byte, value interface{}) error

Types

type Cache

type Cache interface {
	Set(key string, source interface{}, expire int) error
	Get(key string, value interface{}) error
	GetOrSet(key string, handler Handle, value interface{}, expire int) (interface{}, error)
}

type Client

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

func (*Client) Close

func (c *Client) Close()

func (*Client) Decr

func (c *Client) Decr(key string) (int, error)

func (*Client) DecrBy

func (c *Client) DecrBy(key string, count int) (int, error)

func (*Client) Del

func (c *Client) Del(key string) error

func (*Client) Get

func (c *Client) Get(key string, value interface{}) error

func (*Client) GetCounter

func (c *Client) GetCounter(key string) (int, error)

func (*Client) GetOrSet

func (c *Client) GetOrSet(key string, handler Handle, value interface{}, expire int) (interface{}, error)

func (*Client) Incr

func (c *Client) Incr(key string) (int, error)

func (*Client) IncrBy

func (c *Client) IncrBy(key string, count int) (int, error)

func (*Client) Lock

func (c *Client) Lock(key string) bool

func (*Client) LockWithTimeOut

func (c *Client) LockWithTimeOut(key string, timeout int64) bool

func (*Client) RealKey

func (c *Client) RealKey(key string) string

func (*Client) Set

func (c *Client) Set(key string, source interface{}, expire int) error

func (*Client) Unlock

func (c *Client) Unlock(key string) error

type Counter

type Counter interface {
	Incr(key string) (int, error)
	IncrBy(key string, count int) (int, error)
	Decr(key string) (int, error)
	DecrBy(key string, count int) (int, error)
	Del(key string) error
	GetCounter(key string) (int, error)
}

type Handle

type Handle func() (interface{}, error)

type Locker

type Locker interface {
	Lock(key string) bool
	LockWithTimeOut(key string, timeout int64) bool
	Unlock(key string) error
}

type Manager

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

func NewManager

func NewManager(opts Options) *Manager

func (*Manager) NewClient

func (cm *Manager) NewClient(prefix string) (*Client, error)

type Options

type Options struct {
	Prefix    string `json:"prefix" yaml:"prefix" mapstructure:"prefix"`
	Address   string `json:"address" mapstructure:"address"`
	Password  string `json:"password" json:"password" mapstructure:"password"`
	DB        int    `json:"db" yaml:"db" mapstructure:"db"`
	MaxIdle   int    `json:"max_idle" yaml:"max_idle" mapstructure:"max_idle"`
	MaxActive int    `json:"max_active" yaml:"max_active" mapstructure:"max_active"`
	Wait      bool   `json:"wait" yaml:"wait" structure:"wait"`
	// 单位为秒
	IdleTimeout int `json:"idle_timeout" yaml:"idle_timeout" structure:"idle_timeout"`
	// 单位为秒
	Timeout int `json:"timeout" yaml:"timeout" mapstructure:"timeout"`
}

type RedisStore

type RedisStore interface {
	Marshal() ([]byte, error)
	Unmarshal([]byte) (RedisStore, error)
}

Jump to

Keyboard shortcuts

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