redis

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decr

func Decr(key string, expire int) (int64, error)

func Delete

func Delete(key string) error

func Do

func Do(commandName string, args ...interface{}) (reply interface{}, err error)

func Exists

func Exists(key string) (bool, error)

func Flush

func Flush() error

Flush flushes the output buffer to the Redis server.

func GetObject

func GetObject(key string, v interface{}) error

func GetString

func GetString(key string) (string, error)

func HDel

func HDel(hashID string, keys ...interface{}) (int, error)

HDel 删除hash键

func HExists

func HExists(hashID string, key string) (bool, error)

HExists 检查Hash的key是否存在

func HGetAll

func HGetAll(hashID string) ([]interface{}, error)

HGetAll 获取所有Keys和所有Values

func HGetObject

func HGetObject(hashID string, key string, v interface{}) error

HGetObject hash获取值

func HGetString

func HGetString(hashID string, key string) (string, error)

Hash 操作 HGetString hash获取值

func HKeys

func HKeys(hashID string) ([]string, error)

HKeys 获取keys

func HLen

func HLen(hashID string) (int64, error)

HLen 返回Hash的数量

func HMGet

func HMGet(hashID string, keys ...interface{}) ([]interface{}, error)

HMGet 批量获取hash值

func HMSet

func HMSet(hashID string, keyVals []interface{}, expire int) error

HMSet 批量设置hash值

func HSet

func HSet(hashID string, key string, val interface{}, expire int) error

HSet Hash设置值

func HVals

func HVals(hashID string) ([]interface{}, error)

HVals 获取所有值

func Incr

func Incr(key string, expire int) (int64, error)

func Init

func Init(options Options) error

func Keys

func Keys(pattern string) ([]interface{}, error)

func Receive

func Receive() (reply interface{}, err error)

Receive receives a single reply from the Redis server

func Send

func Send(commandName string, args ...interface{}) error

Send writes the command to the client's output buffer.

func SetObject

func SetObject(key string, v interface{}, expire int) error

func SetString

func SetString(key string, strVal string, expire int) error

func TTL

func TTL(key string) (int64, error)

Types

type Cache

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

func GetStdCache

func GetStdCache() *Cache

GetStdCache 获取默认的redis缓存实例

func New

func New(options Options) *Cache

func (*Cache) Decr

func (cache *Cache) Decr(key string, expire int) (int64, error)

Decr 值减一

func (*Cache) Delete

func (cache *Cache) Delete(key string) error

Delete 删除key

func (*Cache) Do

func (cache *Cache) Do(commandName string, args ...interface{}) (reply interface{}, err error)

func (*Cache) Exists

func (cache *Cache) Exists(key string) (bool, error)

Exists 是否存在Key

func (*Cache) Flush

func (cache *Cache) Flush() error

Flush flushes the output buffer to the redigo server.

func (*Cache) GetObject

func (cache *Cache) GetObject(key string, v interface{}) error

func (*Cache) GetString

func (cache *Cache) GetString(key string) (string, error)

func (*Cache) HDel

func (cache *Cache) HDel(hashID string, keys ...interface{}) (int, error)

HDel 删除hash键

func (*Cache) HExists

func (cache *Cache) HExists(hashID string, key string) (bool, error)

HExists 检查Hash的key是否存在

func (*Cache) HGetAll

func (cache *Cache) HGetAll(hashID string) ([]interface{}, error)

HGetAll 获取所有Keys和所有Values

func (*Cache) HGetObject

func (cache *Cache) HGetObject(hashID string, key string, v interface{}) error

HGetObject hash获取值

func (*Cache) HGetString

func (cache *Cache) HGetString(hashID string, key string) (string, error)

HGetString hash获取值

func (*Cache) HKeys

func (cache *Cache) HKeys(hashID string) ([]string, error)

HKeys 获取keys

func (*Cache) HLen

func (cache *Cache) HLen(hashID string) (int64, error)

HLen 返回Hash的数量

func (*Cache) HMGet

func (cache *Cache) HMGet(hashID string, keys []interface{}) ([]interface{}, error)

HMGet 批量获取hash值

func (*Cache) HMSet

func (cache *Cache) HMSet(hashID string, keyVals []interface{}, expire int) error

HMSet 批量设置hash值

func (*Cache) HSet

func (cache *Cache) HSet(hashID string, key string, val interface{}, expire int) error

HSet Hash设置值

func (*Cache) HVals

func (cache *Cache) HVals(hashID string) ([]interface{}, error)

HVals 获取所有值

func (*Cache) Incr

func (cache *Cache) Incr(key string, expire int) (int64, error)

Incr 值加一

func (*Cache) Keys

func (cache *Cache) Keys(pattern string) ([]interface{}, error)

Keys 查找Keys

func (*Cache) Receive

func (cache *Cache) Receive() (reply interface{}, err error)

Receive receives a single reply from the redigo server

func (*Cache) Send

func (cache *Cache) Send(commandName string, args ...interface{}) error

Send writes the command to the client's output buffer.

func (*Cache) SetObject

func (cache *Cache) SetObject(key string, v interface{}, expire int) error

func (*Cache) SetString

func (cache *Cache) SetString(key string, strVal string, expire int) error

SetString 设置字符串Key值, 如果需要持续不过期 expire=math.MaxInt32

func (*Cache) TTL

func (cache *Cache) TTL(key string) (int64, error)

TTL 查询Key的过期时间,单位:秒。 -2 key不存在, -1 无限期

type Checker

type Checker struct{}

Checker Redis 健康检查器

func (*Checker) Check

func (c *Checker) Check() (bool, map[string]string, string)

Check 检查可用状态

func (*Checker) Enabled

func (c *Checker) Enabled() bool

Enabled 是否启用

func (*Checker) GetName

func (c *Checker) GetName() string

GetName 获取名称

type Options

type Options struct {
	// host:port 形式的IP端口地址,或者 MOD:CMD 形式的 L5 地址
	Address        string
	Db             int
	Password       string
	ConnectTimeout time.Duration
	ReadTimeout    time.Duration
	WriteTimeout   time.Duration
	IdleTimeout    time.Duration
	MaxIdle        int
	MaxActive      int
}

func (*Options) Assign

func (options *Options) Assign()

type Script

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

redis 脚本

func NewScript

func NewScript(keyCount int, src string) *Script

NewScript 创建redis脚本

func (*Script) Do

func (script *Script) Do(cache *Cache, keysAndArgs ...interface{}) (interface{}, error)

Jump to

Keyboard shortcuts

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