redis

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KM        GeoUnit = "km"
	M         GeoUnit = "m"
	MI        GeoUnit = "mi"
	FT        GeoUnit = "ft"
	WITHCOORD GeoEnum = "WITHCOORD"
	WITHDIST  GeoEnum = "WITHDIST"
	WITHHASH  GeoEnum = "WITHHASH"
	ASC       GeoEnum = "ASC"
	DESC      GeoEnum = "DESC"
)

长度计量单位

View Source
const (
	LockPrefix = "dlock:"
	LockValue  = "DLOCK"
)

Variables

View Source
var (
	DefaultSerializer = JsonSerializer{}
)

Functions

func GetBucketId

func GetBucketId(key []byte, bit int) []byte
getBucketId

https://www.cnblogs.com/colorfulkoala/p/5783556.html 过程变化简单描述为:get(key1) -> hget(md5(key1), key1) 从而得到value1。 如果我们通过预先计算,让很多key可以在BucketId空间里碰撞,那么可以认为一个BucketId下面挂了多个key。比如平均每个BucketId下面挂10个key,那么理论上我们将会减少超过90%的redis key的个数。 具体实现起来有一些麻烦,而且用这个方法之前你要想好容量规模。我们通常使用的md5是32位的hexString(16进制字符),它的空间是128bit,这个量级太大了,我们需要存储的是百亿级,大约是33bit,所以我们需要有一种机制计算出合适位数的散列,而且为了节约内存,我们需要利用全部字符类型(ASCII码在0~127之间)来填充,而不用HexString,这样Key的长度可以缩短到一半。

func GetSort

func GetSort(sort GeoEnum) string

Types

type Client

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

func (*Client) Close

func (c *Client) Close() error

RandomKey return random Key for db

func (*Client) Delete

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

Delete delete the key, cmd by del

func (*Client) GetExpire

func (c *Client) GetExpire(key string) (time.Duration, error)

SetExpire cmd by TTL

func (*Client) GetGeoOps

func (c *Client) GetGeoOps() Geo

GetGeoOps Geo Returns the operations performed on geo values (also known GIS system).

func (*Client) GetHashOps

func (c *Client) GetHashOps() Hash

GetHashOps Returns the operations performed on hash values.

func (*Client) GetKVOps

func (c *Client) GetKVOps() KV

GetKVOps Returns the operations performed on simple values (or Strings in Redis terminology).

func (*Client) GetListOps

func (c *Client) GetListOps() List

GetListOps Returns the operations performed on list values.

func (*Client) GetLockOps

func (c *Client) GetLockOps() Lock

GetLockOps Returns the operations performed on locker values.

func (*Client) GetSetOps

func (c *Client) GetSetOps() Set

GetSetOps Returns the operations performed on set values.

func (*Client) GetZSetOps

func (c *Client) GetZSetOps() ZSet

GetZSetOps Returns the operations performed on zset values (also known as sorted sets).

func (*Client) HasKey

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

HasKey exists the key, cmd by exists

func (*Client) Ping

func (c *Client) Ping() (string, error)

Ping return PONG and error

func (*Client) RandomKey

func (c *Client) RandomKey() (string, error)

RandomKey return random Key for db

func (*Client) SetExpire

func (c *Client) SetExpire(key string, expiration time.Duration) (bool, error)

SetExpire cmd by expire

func (*Client) SetSerializer

func (c *Client) SetSerializer(serializer ISerializer)

SetSerializer set value serializer

type Geo

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

func (*Geo) GeoAdd

func (geo *Geo) GeoAdd(key string, longitude float64, latitude float64, member string) int64

添加一个地理信息

func (*Geo) GeoAddArr

func (geo *Geo) GeoAddArr(key string, geoPosition []GeoPosition) int64

添加一批地理信息

func (*Geo) GeoDist

func (geo *Geo) GeoDist(key string, member1, member2 string, unit GeoUnit) (error, GeoDistInfo)

* 获取两个坐标的直线距离

func (*Geo) GeoPos

func (geo *Geo) GeoPos(key string, member string) (err error, geoRes GeoPosition)

根据地理位置名称获取经纬度

func (*Geo) GeoPosArr

func (geo *Geo) GeoPosArr(key string, members []string) (err error, geoRes []GeoPosition)

获取一批地理位置的经纬度

func (*Geo) GeoRadius

func (geo *Geo) GeoRadius(key string, query GeoRadiusQuery) (error, []GeoPosition)

* 经纬度中心距离计算

func (*Geo) GeoRadiusByMember

func (geo *Geo) GeoRadiusByMember(key string, query GeoRadiusByMemberQuery) (error, []GeoPosition)

* 地理标识中心距离计算

type GeoDistInfo

type GeoDistInfo struct {
	Unit GeoUnit
	Dist float64
}

type GeoEnum

type GeoEnum string

type GeoPosition

type GeoPosition struct {
	Longitude float64
	Latitude  float64
	Dist      float64
	Member    string
	GeoHash   int64
	Unit      GeoUnit
}

type GeoRadiusByMemberQuery

type GeoRadiusByMemberQuery struct {
	Member      string
	Radius      float64
	Unit        GeoUnit
	WithCoord   bool
	WithDist    bool
	WithGeoHash bool
	Count       int
	// Can be ASC or DESC. Default is no sort order.
	Sort      GeoEnum
	Store     string
	StoreDist string
}

type GeoRadiusQuery

type GeoRadiusQuery struct {
	Longitude   float64
	Latitude    float64
	Radius      float64
	Unit        GeoUnit
	WithCoord   bool
	WithDist    bool
	WithGeoHash bool
	Count       int
	// Can be ASC or DESC. Default is no sort order.
	Sort      GeoEnum
	Store     string
	StoreDist string
}

type GeoUnit

type GeoUnit string

type GoRedisClusterOps

type GoRedisClusterOps struct {
	GoRedisStandaloneOps
}

func NewClusterOps

func NewClusterOps(options *Options) *GoRedisClusterOps

type GoRedisStandaloneOps

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

func NewStandaloneOps

func NewStandaloneOps(options *Options) *GoRedisStandaloneOps

func (*GoRedisStandaloneOps) Append

func (ops *GoRedisStandaloneOps) Append(key string, value string) (int64, error)

func (*GoRedisStandaloneOps) Close

func (ops *GoRedisStandaloneOps) Close() error

func (*GoRedisStandaloneOps) DeleteKey

func (ops *GoRedisStandaloneOps) DeleteKey(keys ...string) (int64, error)

func (*GoRedisStandaloneOps) Exists

func (ops *GoRedisStandaloneOps) Exists(key string) (bool, error)

func (*GoRedisStandaloneOps) GeoAddArr

func (ops *GoRedisStandaloneOps) GeoAddArr(key string, geoLocation ...GeoPosition) int64

func (*GoRedisStandaloneOps) GeoDist

func (ops *GoRedisStandaloneOps) GeoDist(key string, member1, member2 string, unit GeoUnit) (error, GeoDistInfo)

func (*GoRedisStandaloneOps) GeoPos

func (ops *GoRedisStandaloneOps) GeoPos(key string, members ...string) (error, []GeoPosition)

func (*GoRedisStandaloneOps) GeoRadius

func (ops *GoRedisStandaloneOps) GeoRadius(key string, query GeoRadiusQuery) (error, []GeoPosition)

func (*GoRedisStandaloneOps) GeoRadiusByMember

func (ops *GoRedisStandaloneOps) GeoRadiusByMember(key string, member string, query GeoRadiusByMemberQuery) (error, []GeoPosition)

func (*GoRedisStandaloneOps) Get

func (ops *GoRedisStandaloneOps) Get(key string) (string, error)

func (*GoRedisStandaloneOps) GetRange

func (ops *GoRedisStandaloneOps) GetRange(key string, start int64, end int64) (string, error)

func (*GoRedisStandaloneOps) GetValue

func (ops *GoRedisStandaloneOps) GetValue(key string) ([]byte, error)

func (*GoRedisStandaloneOps) HDel

func (ops *GoRedisStandaloneOps) HDel(key string, fields ...string) (int64, error)

func (*GoRedisStandaloneOps) HExists

func (ops *GoRedisStandaloneOps) HExists(key string, field string) (bool, error)

func (*GoRedisStandaloneOps) HGet

func (ops *GoRedisStandaloneOps) HGet(key string, field string) (string, error)

func (*GoRedisStandaloneOps) HGetAll

func (ops *GoRedisStandaloneOps) HGetAll(key string) (map[string]string, error)

func (*GoRedisStandaloneOps) HGetFloat64

func (ops *GoRedisStandaloneOps) HGetFloat64(key string, field string) (float64, error)

func (*GoRedisStandaloneOps) HGetInt64

func (ops *GoRedisStandaloneOps) HGetInt64(key string, field string) (int64, error)

func (*GoRedisStandaloneOps) HIncrBy

func (ops *GoRedisStandaloneOps) HIncrBy(key string, field string, increment int64) (int64, error)

func (*GoRedisStandaloneOps) HKeys

func (ops *GoRedisStandaloneOps) HKeys(key string) ([]string, error)

func (*GoRedisStandaloneOps) HLen

func (ops *GoRedisStandaloneOps) HLen(key string) (int64, error)

func (*GoRedisStandaloneOps) HMGet

func (ops *GoRedisStandaloneOps) HMGet(key string, fields ...string) ([]interface{}, error)

func (*GoRedisStandaloneOps) HSet

func (ops *GoRedisStandaloneOps) HSet(key string, field string, value interface{}) (int64, error)

func (*GoRedisStandaloneOps) HSetNX

func (ops *GoRedisStandaloneOps) HSetNX(key string, field string, value interface{}) (bool, error)

func (*GoRedisStandaloneOps) HVals

func (ops *GoRedisStandaloneOps) HVals(key string) ([]string, error)

func (*GoRedisStandaloneOps) IncrBy

func (ops *GoRedisStandaloneOps) IncrBy(key string, step int64) (int64, error)

func (*GoRedisStandaloneOps) LIndex

func (ops *GoRedisStandaloneOps) LIndex(key string, index int64) (string, error)

func (*GoRedisStandaloneOps) LPop

func (ops *GoRedisStandaloneOps) LPop(key string) (string, error)

--------------------------------------------------------------------------------------------------- list ops

func (*GoRedisStandaloneOps) LPush

func (ops *GoRedisStandaloneOps) LPush(key string, values ...interface{}) (int64, error)

func (*GoRedisStandaloneOps) LRange

func (ops *GoRedisStandaloneOps) LRange(key string, start int64, end int64) ([]string, error)

func (*GoRedisStandaloneOps) LRemove

func (ops *GoRedisStandaloneOps) LRemove(key string, count int64, value interface{}) (int64, error)

func (*GoRedisStandaloneOps) LSet

func (ops *GoRedisStandaloneOps) LSet(key string, index int64, value interface{}) error

func (*GoRedisStandaloneOps) LSize

func (ops *GoRedisStandaloneOps) LSize(key string) (int64, error)

func (*GoRedisStandaloneOps) LTrim

func (ops *GoRedisStandaloneOps) LTrim(key string, start int64, end int64) error

func (*GoRedisStandaloneOps) MultiGet

func (ops *GoRedisStandaloneOps) MultiGet(key ...string) ([]interface{}, error)

func (*GoRedisStandaloneOps) MultiSet

func (ops *GoRedisStandaloneOps) MultiSet(values ...interface{}) error

MultiSet is like Set but accepts multiple values:

  • MSet("key1", "value1", "key2", "value2")
  • MSet([]string{"key1", "value1", "key2", "value2"})
  • MSet(map[string]interface{}{"key1": "value1", "key2": "value2"})

func (*GoRedisStandaloneOps) Ping

func (ops *GoRedisStandaloneOps) Ping() (string, error)

func (*GoRedisStandaloneOps) RPop

func (ops *GoRedisStandaloneOps) RPop(key string) (string, error)

func (*GoRedisStandaloneOps) RPush

func (ops *GoRedisStandaloneOps) RPush(key string, values ...interface{}) (int64, error)

func (*GoRedisStandaloneOps) RandomKey

func (ops *GoRedisStandaloneOps) RandomKey() (string, error)

func (*GoRedisStandaloneOps) SAdd

func (ops *GoRedisStandaloneOps) SAdd(key string, members ...interface{}) (int64, error)

func (*GoRedisStandaloneOps) SCard

func (ops *GoRedisStandaloneOps) SCard(key string) (int64, error)

func (*GoRedisStandaloneOps) SDiff

func (ops *GoRedisStandaloneOps) SDiff(keys ...string) ([]string, error)

func (*GoRedisStandaloneOps) SInter

func (ops *GoRedisStandaloneOps) SInter(keys ...string) ([]string, error)

func (*GoRedisStandaloneOps) SInterStore

func (ops *GoRedisStandaloneOps) SInterStore(destination string, keys ...string) (int64, error)

func (*GoRedisStandaloneOps) SIsMember

func (ops *GoRedisStandaloneOps) SIsMember(key string, member interface{}) (bool, error)

func (*GoRedisStandaloneOps) SMembers

func (ops *GoRedisStandaloneOps) SMembers(key string) ([]string, error)

func (*GoRedisStandaloneOps) SMove

func (ops *GoRedisStandaloneOps) SMove(source string, destination string, member interface{}) (bool, error)

func (*GoRedisStandaloneOps) SPop

func (ops *GoRedisStandaloneOps) SPop(key string) (string, error)

func (*GoRedisStandaloneOps) SRandMembers

func (ops *GoRedisStandaloneOps) SRandMembers(key string, count int64) ([]string, error)

func (*GoRedisStandaloneOps) SRem

func (ops *GoRedisStandaloneOps) SRem(key string, members ...interface{}) (int64, error)

func (*GoRedisStandaloneOps) SUnion

func (ops *GoRedisStandaloneOps) SUnion(keys ...string) ([]string, error)

func (*GoRedisStandaloneOps) SUnionStore

func (ops *GoRedisStandaloneOps) SUnionStore(destination string, keys ...string) (int64, error)

func (*GoRedisStandaloneOps) Set

func (ops *GoRedisStandaloneOps) Set(key string, value string, expiration time.Duration) error

func (*GoRedisStandaloneOps) SetExpire

func (ops *GoRedisStandaloneOps) SetExpire(key string, expiration time.Duration) (bool, error)

func (*GoRedisStandaloneOps) SetNX

func (ops *GoRedisStandaloneOps) SetNX(key string, value interface{}) (bool, error)

func (*GoRedisStandaloneOps) SetValue

func (ops *GoRedisStandaloneOps) SetValue(key string, value interface{}, expiration time.Duration) error

func (*GoRedisStandaloneOps) StrLen

func (ops *GoRedisStandaloneOps) StrLen(key string) (int64, error)

func (*GoRedisStandaloneOps) TTL

func (ops *GoRedisStandaloneOps) TTL(key string) (time.Duration, error)

func (*GoRedisStandaloneOps) ZAdd

func (ops *GoRedisStandaloneOps) ZAdd(key string, member ZMember) int64

func (*GoRedisStandaloneOps) ZCard

func (ops *GoRedisStandaloneOps) ZCard(key string) int64

func (*GoRedisStandaloneOps) ZCount

func (ops *GoRedisStandaloneOps) ZCount(key, min, max string) int64

func (*GoRedisStandaloneOps) ZIncrby

func (ops *GoRedisStandaloneOps) ZIncrby(key string, incr float64, member string) float64

func (*GoRedisStandaloneOps) ZInterStore

func (ops *GoRedisStandaloneOps) ZInterStore(destination string, store []ZStore, arg ZStoreEnum) int64

func (*GoRedisStandaloneOps) ZLexCount

func (ops *GoRedisStandaloneOps) ZLexCount(key, min, max string) int64

func (*GoRedisStandaloneOps) ZRange

func (ops *GoRedisStandaloneOps) ZRange(key string, start, stop int64) []string

func (*GoRedisStandaloneOps) ZRangeByLex

func (ops *GoRedisStandaloneOps) ZRangeByLex(key, min, max string, offset int64, count int64) []string

func (*GoRedisStandaloneOps) ZRangeByScore

func (ops *GoRedisStandaloneOps) ZRangeByScore(key, min, max string, offset int64, count int64) []string

func (*GoRedisStandaloneOps) ZRank

func (ops *GoRedisStandaloneOps) ZRank(key, member string) int64

func (*GoRedisStandaloneOps) ZRem

func (ops *GoRedisStandaloneOps) ZRem(key string, member ...string) int64

func (*GoRedisStandaloneOps) ZRemRangeByLex

func (ops *GoRedisStandaloneOps) ZRemRangeByLex(key, min, max string) int64

func (*GoRedisStandaloneOps) ZRemRangeByRank

func (ops *GoRedisStandaloneOps) ZRemRangeByRank(key string, start, stop int64) int64

func (*GoRedisStandaloneOps) ZRevRange

func (ops *GoRedisStandaloneOps) ZRevRange(key string, start, stop int64) []string

func (*GoRedisStandaloneOps) ZRevRangeWithScores

func (ops *GoRedisStandaloneOps) ZRevRangeWithScores(key string, start, stop int64) ([]ZMember, error)

func (*GoRedisStandaloneOps) ZRevRank

func (ops *GoRedisStandaloneOps) ZRevRank(key, member string) int64

func (*GoRedisStandaloneOps) ZScore

func (ops *GoRedisStandaloneOps) ZScore(key, member string) float64

type Hash

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

func (Hash) Delete

func (h Hash) Delete(key string, hashKey string) error

Delete delete hashset for key and hash key

func (Hash) Exists

func (h Hash) Exists(key string, hashKey string) bool

Exists has key and hash key

func (Hash) Get

func (h Hash) Get(key string, hashKey string, value interface{}) error

Get get value(struct , int64, float64) for the key and hash key

func (Hash) GetEntries

func (h Hash) GetEntries(key string) (map[string]string, error)

GetEntries get all hash keys and values

func (Hash) GetHashKeys

func (h Hash) GetHashKeys(key string) ([]string, error)

GetHashKeys get hask keys for the key

func (Hash) GetString

func (h Hash) GetString(key string, hashKey string) (string, error)

GetString get string for key and hash key

func (Hash) Increment

func (h Hash) Increment(key string, hashKey string, delta int64) int64

Increment increment value by delta step to the key and hash key

func (Hash) MultiGet

func (h Hash) MultiGet(key string, hashKeys ...string) ([]interface{}, error)

MultiGet get all values for the keys

func (Hash) Put

func (h Hash) Put(key string, hashKey string, value interface{}) error

Put put value (struct , int64, float64) to the key and hash key

func (Hash) PutIfAbsent

func (h Hash) PutIfAbsent(key string, hashKey string, value interface{}) (bool, error)

Put put value (struct , int64, float64) to the key and hash key; cmd by SetNx .

func (Hash) Size

func (h Hash) Size(key string) int64

Size get len by key's all hash size

type IClient

type IClient interface {
	//SetSerializer set value serializer
	SetSerializer(ISerializer)
	//GetKVOps Returns the operations performed on simple values (or Strings in Redis terminology).
	GetKVOps() KV
	//GetListOps Returns the operations performed on list values.
	GetListOps() List
	//GetHashOps Returns the operations performed on hash values.
	GetHashOps() Hash
	//GetSetOps Returns the operations performed on set values.
	GetSetOps() Set
	//GetZSetOps Returns the operations performed on zset values (also known as sorted sets).
	GetZSetOps() ZSet
	//GetGeoOps Geo Returns the operations performed on geo values (also known GIS system).
	GetGeoOps() Geo
	//GetLockOps Returns the operations performed on locker values.
	GetLockOps() Lock
	Close() error
	// SetExpire cmd by expire
	Ping() (string, error)
	// SetExpire cmd by expire
	SetExpire(key string, expiration time.Duration) (bool, error)
	// SetExpire cmd by TTL
	GetExpire(key string) (time.Duration, error)
	// Delete delete the key, cmd by del
	Delete(key string) bool
	// HasKey exists the key, cmd by exists
	HasKey(key string) bool
	// RandomKey return random Key for db
	RandomKey() (string, error)
}

IClient redis client interface

func NewClient

func NewClient(options *Options) IClient

NewClient new redis client by Options

type ISerializer

type ISerializer interface {
	Serialization(value interface{}) ([]byte, error)
	Deserialization(byt []byte, ptr interface{}) (err error)
}

type JsonSerializer

type JsonSerializer struct {
}

func (JsonSerializer) Deserialization

func (serializer JsonSerializer) Deserialization(byt []byte, ptr interface{}) (err error)

func (JsonSerializer) Serialization

func (serializer JsonSerializer) Serialization(value interface{}) ([]byte, error)

type KV

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

func (KV) Append

func (kv KV) Append(key string, value string) int64

Append append string,to the string

func (KV) Get

func (kv KV) Get(key string, ptr interface{}) error

Get get serialization object for the key

func (KV) GetAndSet

func (kv KV) GetAndSet(key string, value string) (string, error)

GetAndSet get value for the key , and that if it's null, set value to the key.

func (KV) GetString

func (kv KV) GetString(key string) (string, error)

Get get string for the key

func (KV) Increment

func (kv KV) Increment(key string, delta int64) (int64, error)

Increment Increment delta step value(-x,x) for the key

func (KV) MultiGet

func (kv KV) MultiGet(keys ...string) ([]interface{}, error)

MultiGet is like Get but accepts multiple keys:

func (KV) MultiSet

func (kv KV) MultiSet(values ...interface{}) error

MultiSet is like Set but accepts multiple values:

  • MSet("key1", "value1", "key2", "value2")
  • MSet([]string{"key1", "value1", "key2", "value2"})
  • MSet(map[string]interface{}{"key1": "value1", "key2": "value2"})

func (KV) Set

func (kv KV) Set(key string, value interface{}, duration time.Duration) error

Set set serialization object to the key

func (KV) SetIfAbsent

func (kv KV) SetIfAbsent(key string, value interface{}) (bool, error)

Set set serialization object to the key, redis cmd: setnx

func (KV) SetString

func (kv KV) SetString(key string, value string, duration time.Duration) error

Get string for the key

type List

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

the List elements type is string

func (List) AddElements

func (ls List) AddElements(key string, values ...interface{}) error

AddElements add serialization elements to key list

func (List) Clear

func (ls List) Clear(key string) (bool, error)

Clear clear the key List

func (List) GetElement

func (ls List) GetElement(key string, index int64, elem interface{}) error

GetElement get serialization element for key list

func (List) GetElements

func (ls List) GetElements(key string, startIndex int64, endIndex int64, elements interface{})

GetElements get serialization elements for key list

func (List) Index

func (ls List) Index(key string, index int64) (string, error)

Index get index elements from key List

func (List) LeftPop

func (ls List) LeftPop(key string) (string, error)

LeftPop left pop the element from key List

func (List) LeftPush

func (ls List) LeftPush(key string, value ...interface{}) (int64, error)

LeftPush left push element to key List

func (List) Range

func (ls List) Range(key string, start int64, end int64) ([]string, error)

Range get range elements(strings.) with key List by start and end index

func (List) Remove

func (ls List) Remove(key string, count int64, value interface{}) (int64, error)

Remove remove count number elements from key List, if

func (List) RightPop

func (ls List) RightPop(key string) (string, error)

RightPop right pop the element from key List ,that remove it.

func (List) RightPush

func (ls List) RightPush(key string, values ...interface{}) (int64, error)

RightPush right push element to key List

func (List) Set

func (ls List) Set(key string, index int64, value interface{}) error

Set set element to key List by index

func (List) Size

func (ls List) Size(key string) (int64, error)

Size the key List of size

func (List) Trim

func (ls List) Trim(key string, start int64, end int64) error

Trim trim range(start-end index) with key List ,and then remove the others.

type Lock

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

func (*Lock) DisposeLock

func (lock *Lock) DisposeLock(key string) (error, bool)

* 释放锁

func (*Lock) GetDLock

func (lock *Lock) GetDLock(key string, waitSecond int) (error, bool)

* 获取一个锁,如果锁的key已经存在根据传入的第二个参数的时间进行等待,直到超时或者拿到锁为止。 切记业务完成后一定要及时释放锁。

type Ops

type Ops interface {
	Close() error
	Ping() (string, error)
	DeleteKey(keys ...string) (int64, error)
	Exists(key string) (bool, error)
	SetExpire(key string, expiration time.Duration) (bool, error)
	TTL(key string) (time.Duration, error)
	MultiSet(values ...interface{}) error
	SetValue(key string, value interface{}, expiration time.Duration) error
	Set(key string, value string, expiration time.Duration) error
	SetNX(key string, value interface{}) (bool, error)
	Get(key string) (string, error)
	GetValue(key string) ([]byte, error)
	Append(key string, value string) (int64, error)
	StrLen(key string) (int64, error)
	GetRange(key string, start int64, end int64) (string, error)
	RandomKey() (string, error)
	MultiGet(key ...string) ([]interface{}, error)
	IncrBy(key string, step int64) (int64, error)
	LIndex(key string, index int64) (string, error)
	LPop(key string) (string, error)
	LPush(key string, values ...interface{}) (int64, error)
	LRange(key string, start int64, end int64) ([]string, error)
	LTrim(key string, start int64, end int64) error
	RPop(key string) (string, error)
	RPush(key string, values ...interface{}) (int64, error)
	LSet(key string, index int64, value interface{}) error
	LSize(key string) (int64, error)
	LRemove(key string, count int64, value interface{}) (int64, error)
	GeoAddArr(key string, geoLocation ...GeoPosition) int64
	GeoPos(key string, members ...string) (error, []GeoPosition)
	GeoDist(key string, member1, member2 string, unit GeoUnit) (error, GeoDistInfo)
	GeoRadius(key string, query GeoRadiusQuery) (error, []GeoPosition)
	GeoRadiusByMember(key string, member string, query GeoRadiusByMemberQuery) (error, []GeoPosition)
	SAdd(key string, members ...interface{}) (int64, error)
	SDiff(keys ...string) ([]string, error)
	SCard(key string) (int64, error)
	SInter(keys ...string) ([]string, error)
	SInterStore(destination string, keys ...string) (int64, error)
	SIsMember(key string, member interface{}) (bool, error)
	SMembers(key string) ([]string, error)
	SMove(source string, destination string, member interface{}) (bool, error)
	SPop(key string) (string, error)
	SRandMembers(key string, count int64) ([]string, error)
	SRem(key string, members ...interface{}) (int64, error)
	SUnion(keys ...string) ([]string, error)
	SUnionStore(destination string, keys ...string) (int64, error)
	HDel(key string, fields ...string) (int64, error)
	HExists(key string, field string) (bool, error)
	HGet(key string, field string) (string, error)
	HGetAll(key string) (map[string]string, error)
	HIncrBy(key string, field string, increment int64) (int64, error)
	HKeys(key string) ([]string, error)
	HLen(key string) (int64, error)
	HMGet(key string, fields ...string) ([]interface{}, error)
	HSet(key string, field string, value interface{}) (int64, error)
	HSetNX(key string, field string, value interface{}) (bool, error)
	HVals(key string) ([]string, error)
	ZAdd(key string, member ZMember) int64
	ZCard(key string) int64
	ZCount(key, min, max string) int64
	ZIncrby(key string, incr float64, member string) float64
	ZInterStore(destination string, store []ZStore, arg ZStoreEnum) int64
	ZLexCount(key, min, max string) int64
	ZRange(key string, start, stop int64) []string
	ZRangeByLex(key, min, max string, offset int64, count int64) []string
	ZRangeByScore(key, min, max string, offset int64, count int64) []string
	ZRank(key, member string) int64
	ZRem(key string, member ...string) int64
	ZRemRangeByLex(key, min, max string) int64
	ZRemRangeByRank(key string, start, stop int64) int64
	ZRevRange(key string, start, stop int64) []string
	ZRevRangeWithScores(key string, start, stop int64) ([]ZMember, error)
	ZRevRank(key, member string) int64
	ZScore(key, member string) float64
}

type Options

type Options struct {
	Addr     string
	Addrs    []string
	Password string
	DB       int
}

type Set

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

func (Set) Add

func (set Set) Add(key string, members ...interface{}) (int64, error)

func (Set) Difference

func (set Set) Difference(keys ...string) ([]string, error)

func (Set) Intersect

func (set Set) Intersect(keys ...string) ([]string, error)

func (Set) IntersectAndStore

func (set Set) IntersectAndStore(destination string, keys ...string) (int64, error)

func (Set) IsMember

func (set Set) IsMember(key string, member interface{}) (bool, error)

func (Set) Members

func (set Set) Members(key string) ([]string, error)

func (Set) Move

func (set Set) Move(source string, destination string, member interface{}) (bool, error)

func (Set) Pop

func (set Set) Pop(key string) (string, error)

func (Set) RandMembers

func (set Set) RandMembers(key string, count int64) ([]string, error)

func (Set) Remove

func (set Set) Remove(key string, members ...interface{}) (int64, error)

func (Set) Size

func (set Set) Size(key string) (int64, error)

func (Set) Union

func (set Set) Union(keys ...string) ([]string, error)

func (Set) UnionAndStore

func (set Set) UnionAndStore(destination string, keys ...string) (int64, error)

type ZMember

type ZMember struct {
	Score  float64
	Member string
}

type ZSet

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

func (*ZSet) ZAdd

func (zSet *ZSet) ZAdd(key string, member ZMember) int64

func (*ZSet) ZCard

func (zSet *ZSet) ZCard(key string) int64

func (*ZSet) ZCount

func (zSet *ZSet) ZCount(key string, min, max float64) int64

func (*ZSet) ZIncrby

func (zSet *ZSet) ZIncrby(key string, incr float64, member string) float64

func (*ZSet) ZInterStore

func (zSet *ZSet) ZInterStore(destination string, store []ZStore, arg ZStoreEnum) int64

func (*ZSet) ZLexCount

func (zSet *ZSet) ZLexCount(key, min, max string) int64

func (*ZSet) ZRange

func (zSet *ZSet) ZRange(key string, start, stop int64) []string

func (*ZSet) ZRangeByLex

func (zSet *ZSet) ZRangeByLex(key, min, max string, offset int64, count int64) []string

func (*ZSet) ZRangeByScore

func (zSet *ZSet) ZRangeByScore(key, min, max string, offset int64, count int64) []string

func (*ZSet) ZRank

func (zSet *ZSet) ZRank(key, member string) int64

func (*ZSet) ZRem

func (zSet *ZSet) ZRem(key string, member ...string) int64

func (*ZSet) ZRemRangeByLex

func (zSet *ZSet) ZRemRangeByLex(key, min, max string) int64

func (*ZSet) ZRemRangeByRank

func (zSet *ZSet) ZRemRangeByRank(key string, start, stop int64) int64

func (*ZSet) ZRevRange

func (zSet *ZSet) ZRevRange(key string, start, stop int64) []string

func (*ZSet) ZRevRangeWithScores

func (zSet *ZSet) ZRevRangeWithScores(key string, start, stop int64) ([]ZMember, error)

func (*ZSet) ZRevRank

func (zSet *ZSet) ZRevRank(key, member string) int64

func (*ZSet) ZScore

func (zSet *ZSet) ZScore(key, member string) float64

type ZStore

type ZStore struct {
	Key    string
	Weight float64
}

type ZStoreEnum

type ZStoreEnum string
const (
	MAX ZStoreEnum = "MAX"
	MIN ZStoreEnum = "MIN"
	SUM ZStoreEnum = "SUM"
)

Jump to

Keyboard shortcuts

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