cache

package
v0.41.8 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidConn 无法获取与 redis-server 的连接
	ErrInvalidConn = errors.New("invalid conn")
	// ErrInvalidParamCount 参数数量错误
	ErrInvalidParamCount = errors.New("invalid param count")

	// ErrNil 当无内容时
	ErrNil = redis.ErrNil
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Open() error
	Close() error
	DO(cmd string, args ...interface{}) (interface{}, error)
	Conn() Conn

	Convert
	Key
	String
	Hash
	List
	Set
	SortedSet
	// contains filtered or unexported methods
}

Cache 缓存

func NewCache

func NewCache(opts ...Option) Cache

NewCache ..

type Conn

type Conn interface {
	redis.Conn
}

Conn ..

type Convert added in v0.22.5

type Convert interface {
	Int(reply interface{}, err error) (int, error)
	Int64(reply interface{}, err error) (int64, error)
	Uint64(reply interface{}, err error) (uint64, error)
	Float64(reply interface{}, err error) (float64, error)
	String(reply interface{}, err error) (string, error)
	Bytes(reply interface{}, err error) ([]byte, error)
	Bool(reply interface{}, err error) (bool, error)
	Float64s(reply interface{}, err error) ([]float64, error)
	Int64s(reply interface{}, err error) ([]int64, error)
	Ints(reply interface{}, err error) ([]int, error)
	ByteSlices(reply interface{}, err error) ([][]byte, error)
	Strings(reply interface{}, err error) ([]string, error)
	StringMap(reply interface{}, err error) (map[string]string, error)
	IntMap(reply interface{}, err error) (map[string]int, error)
	Int64Map(reply interface{}, err error) (map[string]int64, error)
	Values(reply interface{}, err error) ([]interface{}, error)
}

Convert 数据转换

type Hash added in v0.14.2

type Hash interface {
	HGet(key, field string) (string, error)
	HSet(key, field string, value interface{}) error
	HMGet(v ...interface{}) ([]string, error)
	HMSet(v ...interface{}) error
	HGetAll(key string) ([]string, error)
	HExists(key, field string) (bool, error)
	HDel(v ...interface{}) (int, error)
	HLen(key string) (int, error)
	HIncrby(key, field string, increment int) (int, error)
	HIncrbyFloat(key, field string, increment float64) (float64, error)
}

Hash 哈希表

type Key added in v0.14.2

type Key interface {
	Del(key ...interface{}) (int, error)
	Exists(key string) (bool, error)
	Expire(key, ex string) (bool, error)
	ExpireAt(key string, t int) (bool, error)
	PExpire(key, ex string) (bool, error)
	PExpireAt(key string, t int) (bool, error)
	TTL(key string) (int, error)
	PTTL(key string) (int, error)
}

Key 键

type List added in v0.14.2

type List interface {
	LPush(v ...interface{}) (int, error)
	LPop(key string) (string, error)
	RPush(v ...interface{}) (int, error)
	RPop(key string) (string, error)
	RPopLPush(source, destination string) (string, error)
	LTrim(key string, start, stop int) error
	LSet(key string, index int, value string) error
	LRem(key string, count int, value string) (int, error)
	LRange(key string, start, stop int) ([]string, error)
	LLen(key string) (int, error)
	LInsertBefore(key, pivot, value string) (int, error)
	LInsertAfter(key, pivot, value string) (int, error)
	LIndex(key string, index int) (string, error)
}

List 列表

type Option

type Option func(Cache)

Option ..

func WithDB

func WithDB(db int) Option

WithDB 0-15

func WithDialConnectTimeout added in v0.34.6

func WithDialConnectTimeout(timeout time.Duration) Option

WithDialConnectTimeout ..

func WithDialReadTimeout added in v0.34.6

func WithDialReadTimeout(timeout time.Duration) Option

WithDialReadTimeout ..

func WithDialWriteTimeout added in v0.34.6

func WithDialWriteTimeout(timeout time.Duration) Option

WithDialWriteTimeout ..

func WithHost

func WithHost(host string) Option

WithHost 地址

func WithIdleTimeout

func WithIdleTimeout(timeout time.Duration) Option

WithIdleTimeout ..

func WithMaxActive

func WithMaxActive(maxActive int) Option

WithMaxActive ..

func WithMaxIdle

func WithMaxIdle(maxIdle int) Option

WithMaxIdle ..

func WithPassword

func WithPassword(password string) Option

WithPassword 密码

func WithPort

func WithPort(port int) Option

WithPort 端口号

func WithWait

func WithWait(wait bool) Option

WithWait ..

type Set added in v0.14.2

type Set interface {
	SAdd(v ...interface{}) (int, error)
	SCard(key string) (int, error)
	SDiff(key ...interface{}) ([]string, error)
	SDiffStore(key ...interface{}) (int, error)
	SUnion(key ...interface{}) ([]string, error)
	SUnionStore(key ...interface{}) (int, error)
	SInter(key ...interface{}) ([]string, error)
	SInterStore(key ...interface{}) (int, error)
	SIsMember(key, member string) (bool, error)
	SMembers(key string) ([]string, error)
	SPop(key string) (string, error)
	SRandMember(key string, count int) ([]string, error)
	SRem(v ...interface{}) (int, error)
}

Set 集合

type SortedSet added in v0.14.2

type SortedSet interface {
	ZAdd(v ...interface{}) (int, error)
	ZCard(key string) (int, error)
	ZCount(key string, min int, max int) (int, error)
	ZIncrby(key, member string, incrment int) (int, error)
	ZRange(key string, start, stop int) ([]string, error)
	ZRangeWithScores(key string, start, stop int) ([]string, error)
	ZScore(key, member string) (int, error)
	ZRank(key, member string) (int, error)
	ZRangeByScore(key string, min, max, limit, offset, count int) ([]string, error)
	ZRevRank(key, member string) (int, error)
	ZRevRangeByScore(key string, max, min, limit, offset, count int) ([]string, error)
	ZRevRange(key string, start, stop int) ([]string, error)
	ZRemRangeByScore(key string, min, max int) (int, error)
	ZRemRangeByRank(key string, start, stop int) (int, error)
	ZRem(v ...interface{}) (int, error)
}

SortedSet 有序集合

type String added in v0.14.2

type String interface {
	Get(key string) (string, error)
	Set(key string, value interface{}) error
	SetEx(key string, value interface{}, seconds string) error
	PSetEx(key string, value interface{}, milliseconds string) error
	MGet(key ...interface{}) ([]string, error)
	MSet(v ...interface{}) error
	Append(key string, value interface{}) (int, error)
	Strlen(key string) (int, error)
	Incr(key string) (int64, error)
	Incrby(key string, increment int64) (int64, error)
	Decr(key string) (int64, error)
	Decrby(key string, decrement int64) (int64, error)
	GetSet(key string, value interface{}) (string, error)
}

String 字符串

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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