redis

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Unlicense Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewCacheClient

func NewCacheClient(ops Options) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) CounterKey

func (c *Client) CounterKey(part string) string

func (*Client) Decr

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

计数器自减

func (*Client) DecrBy

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

func (*Client) Get

func (c *Client) Get(key string) (string, error)

func (*Client) GetCounter

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

获取计数器当前值

func (*Client) Incr

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

计数器自增

func (*Client) IncrBy

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

func (*Client) Lock

func (c *Client) Lock(key string, expireTime ...int) error

通过 redis 加分布式锁

func (*Client) Remove

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

func (*Client) Set

func (c *Client) Set(key, value string, expireTime ...int) error

func (*Client) Unlock

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

解锁

type Options

type Options struct {
	Addr     string `yaml:"addr" mapstructure:"addr"`
	Password string `yaml:"password" mapstructure:"password"`
	DB       int    `yaml:"db" mapstructure:"db"`
	PoolSize int    `yaml:"pool_size" mapstructure:"pool_size"`
	// 读写超时时间
	TimeOut int `yaml:"timeout" mapstructure:"timeout"`
	// 缓存 key 统一前缀
	Prefix string `yaml:"prefix" mapstructure:"prefix"`
}

Jump to

Keyboard shortcuts

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