redis

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClusterType = "cluster"
	NodeType    = "node"
	Nil         = red.Nil
)

Variables

View Source
var (
	ErrEmptyHost = errors.New("empty redis host")
	ErrEmptyType = errors.New("empty redis type")
	ErrEmptyKey  = errors.New("empty redis key")
)
View Source
var ErrNilNode = errors.New("nil redis node")

Functions

This section is empty.

Types

type ClosableNode

type ClosableNode interface {
	RedisNode
	Close()
}

func CreateBlockingNode

func CreateBlockingNode(r *Redis) (ClosableNode, error)

type FloatCmd

type FloatCmd = red.FloatCmd

type GeoLocation

type GeoLocation = red.GeoLocation

GeoLocation is used with GeoAdd to add geospatial location.

type GeoPos

type GeoPos = red.GeoPos

type GeoRadiusQuery

type GeoRadiusQuery = red.GeoRadiusQuery

GeoRadiusQuery is used with GeoRadius to query geospatial index.

type IntCmd

type IntCmd = red.IntCmd

type Map

type Map map[string]string

type Pair

type Pair struct {
	Key   string
	Score int64
}

type Pipeliner

type Pipeliner = red.Pipeliner

type Redis

type Redis struct {
	Addr string
	Type string
	Pass string
	// contains filtered or unexported fields
}

thread-safe

func NewRedis

func NewRedis(redisAddr, redisType string, redisPass ...string) *Redis

func (*Redis) Blpop

func (s *Redis) Blpop(redisNode RedisNode, key string) (string, error)

Use passed in redis connection to execute blocking queries Doesn't benefit from pooling redis connections of blocking queries

func (*Redis) BlpopEx

func (s *Redis) BlpopEx(redisNode RedisNode, key string) (string, bool, error)

func (*Redis) Del

func (s *Redis) Del(keys ...string) (val int, err error)

func (*Redis) Eval

func (s *Redis) Eval(script string, keys []string, args ...interface{}) (val interface{}, err error)

func (*Redis) Exists

func (s *Redis) Exists(key string) (val bool, err error)

func (*Redis) Expire

func (s *Redis) Expire(key string, seconds int) error

func (*Redis) Expireat

func (s *Redis) Expireat(key string, expireTime int64) error

func (*Redis) GeoAdd

func (s *Redis) GeoAdd(key string, geoLocation ...*GeoLocation) (val int64, err error)

func (*Redis) GeoDist

func (s *Redis) GeoDist(key string, member1, member2, unit string) (val float64, err error)

func (*Redis) GeoHash

func (s *Redis) GeoHash(key string, members ...string) (val []string, err error)

func (*Redis) GeoPos

func (s *Redis) GeoPos(key string, members ...string) (val []*GeoPos, err error)

func (*Redis) GeoRadius

func (s *Redis) GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) (val []GeoLocation, err error)

func (*Redis) GeoRadiusByMember

func (s *Redis) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) (val []GeoLocation, err error)

func (*Redis) Get

func (s *Redis) Get(key string) (val string, err error)

func (*Redis) GetBit

func (s *Redis) GetBit(key string, offset int64) (val int, err error)

func (*Redis) Hdel

func (s *Redis) Hdel(key, field string) (val bool, err error)

func (*Redis) Hexists

func (s *Redis) Hexists(key, field string) (val bool, err error)

func (*Redis) Hget

func (s *Redis) Hget(key, field string) (val string, err error)

func (*Redis) Hgetall

func (s *Redis) Hgetall(key string) (val map[string]string, err error)

func (*Redis) Hincrby

func (s *Redis) Hincrby(key, field string, increment int) (val int, err error)

func (*Redis) Hkeys

func (s *Redis) Hkeys(key string) (val []string, err error)

func (*Redis) Hlen

func (s *Redis) Hlen(key string) (val int, err error)

func (*Redis) Hmget

func (s *Redis) Hmget(key string, fields ...string) (val []string, err error)

func (*Redis) Hmset

func (s *Redis) Hmset(key string, fieldsAndValues map[string]string) error

func (*Redis) Hset

func (s *Redis) Hset(key, field, value string) error

func (*Redis) Hsetnx

func (s *Redis) Hsetnx(key, field, value string) (val bool, err error)

func (*Redis) Hvals

func (s *Redis) Hvals(key string) (val []string, err error)

func (*Redis) Incr

func (s *Redis) Incr(key string) (val int64, err error)

func (*Redis) Incrby

func (s *Redis) Incrby(key string, increment int64) (val int64, err error)

func (*Redis) Keys

func (s *Redis) Keys(pattern string) (val []string, err error)

func (*Redis) Llen

func (s *Redis) Llen(key string) (val int, err error)

func (*Redis) Lpop

func (s *Redis) Lpop(key string) (val string, err error)

func (*Redis) Lpush

func (s *Redis) Lpush(key string, values ...interface{}) (val int, err error)

func (*Redis) Lrange

func (s *Redis) Lrange(key string, start int, stop int) (val []string, err error)

func (*Redis) Lrem

func (s *Redis) Lrem(key string, count int, value string) (val int, err error)

func (*Redis) Mget

func (s *Redis) Mget(keys ...string) (val []string, err error)

func (*Redis) Persist

func (s *Redis) Persist(key string) (val bool, err error)

func (*Redis) Pfadd

func (s *Redis) Pfadd(key string, values ...interface{}) (val bool, err error)

func (*Redis) Pfcount

func (s *Redis) Pfcount(key string) (val int64, err error)

func (*Redis) Pfmerge

func (s *Redis) Pfmerge(dest string, keys ...string) error

func (*Redis) Ping

func (s *Redis) Ping() (val bool)

func (*Redis) Pipelined

func (s *Redis) Pipelined(fn func(Pipeliner) error) (err error)

func (*Redis) Rpush

func (s *Redis) Rpush(key string, values ...interface{}) (val int, err error)

func (*Redis) Sadd

func (s *Redis) Sadd(key string, values ...interface{}) (val int, err error)

func (*Redis) Scan

func (s *Redis) Scan(cursor uint64, match string, count int64) (keys []string, cur uint64, err error)

func (*Redis) Scard

func (s *Redis) Scard(key string) (val int64, err error)

func (*Redis) Sdiff

func (s *Redis) Sdiff(keys ...string) (val []string, err error)

func (*Redis) Sdiffstore

func (s *Redis) Sdiffstore(destination string, keys ...string) (val int, err error)

func (*Redis) Set

func (s *Redis) Set(key string, value string) error

func (*Redis) SetBit

func (s *Redis) SetBit(key string, offset int64, value int) error

func (*Redis) Setex

func (s *Redis) Setex(key, value string, seconds int) error

func (*Redis) Setnx

func (s *Redis) Setnx(key, value string) (val bool, err error)

func (*Redis) SetnxEx

func (s *Redis) SetnxEx(key, value string, seconds int) (val bool, err error)

func (*Redis) Sismember

func (s *Redis) Sismember(key string, value interface{}) (val bool, err error)

func (*Redis) Smembers

func (s *Redis) Smembers(key string) (val []string, err error)

func (*Redis) Spop

func (s *Redis) Spop(key string) (val string, err error)

func (*Redis) Srandmember

func (s *Redis) Srandmember(key string, count int) (val []string, err error)

func (*Redis) Srem

func (s *Redis) Srem(key string, values ...interface{}) (val int, err error)

func (*Redis) Sscan

func (s *Redis) Sscan(key string, cursor uint64, match string, count int64) (keys []string, cur uint64, err error)

func (*Redis) String

func (s *Redis) String() string

func (*Redis) Sunion

func (s *Redis) Sunion(keys ...string) (val []string, err error)

func (*Redis) Sunionstore

func (s *Redis) Sunionstore(destination string, keys ...string) (val int, err error)

func (*Redis) Ttl

func (s *Redis) Ttl(key string) (val int, err error)

func (*Redis) ZRevRangeWithScores

func (s *Redis) ZRevRangeWithScores(key string, start, stop int64) (val []Pair, err error)

func (*Redis) Zadd

func (s *Redis) Zadd(key string, score int64, value string) (val bool, err error)

func (*Redis) Zadds

func (s *Redis) Zadds(key string, ps ...Pair) (val int64, err error)

func (*Redis) Zcard

func (s *Redis) Zcard(key string) (val int, err error)

func (*Redis) Zcount

func (s *Redis) Zcount(key string, start, stop int64) (val int, err error)

func (*Redis) Zincrby

func (s *Redis) Zincrby(key string, increment int64, field string) (val int64, err error)

func (*Redis) Zrange

func (s *Redis) Zrange(key string, start, stop int64) (val []string, err error)

func (*Redis) ZrangeWithScores

func (s *Redis) ZrangeWithScores(key string, start, stop int64) (val []Pair, err error)

func (*Redis) ZrangebyscoreWithScores

func (s *Redis) ZrangebyscoreWithScores(key string, start, stop int64) (val []Pair, err error)

func (*Redis) ZrangebyscoreWithScoresAndLimit

func (s *Redis) ZrangebyscoreWithScoresAndLimit(key string, start, stop int64, page, size int) (
	val []Pair, err error)

func (*Redis) Zrank

func (s *Redis) Zrank(key, field string) (val int64, err error)

func (*Redis) Zrem

func (s *Redis) Zrem(key string, values ...interface{}) (val int, err error)

func (*Redis) Zremrangebyrank

func (s *Redis) Zremrangebyrank(key string, start, stop int64) (val int, err error)

func (*Redis) Zremrangebyscore

func (s *Redis) Zremrangebyscore(key string, start, stop int64) (val int, err error)

func (*Redis) Zrevrange

func (s *Redis) Zrevrange(key string, start, stop int64) (val []string, err error)

func (*Redis) ZrevrangebyscoreWithScores

func (s *Redis) ZrevrangebyscoreWithScores(key string, start, stop int64) (val []Pair, err error)

func (*Redis) ZrevrangebyscoreWithScoresAndLimit

func (s *Redis) ZrevrangebyscoreWithScoresAndLimit(key string, start, stop int64, page, size int) (
	val []Pair, err error)

func (*Redis) Zrevrank

func (s *Redis) Zrevrank(key string, field string) (val int64, err error)

func (*Redis) Zscore

func (s *Redis) Zscore(key string, value string) (val int64, err error)

type RedisConf

type RedisConf struct {
	Host string
	Type string `json:",default=node,options=node|cluster"`
	Pass string `json:",optional"`
}

func (RedisConf) NewRedis

func (rc RedisConf) NewRedis() *Redis

func (RedisConf) Validate

func (rc RedisConf) Validate() error

type RedisKeyConf

type RedisKeyConf struct {
	RedisConf
	Key string `json:",optional"`
}

func (RedisKeyConf) Validate

func (rkc RedisKeyConf) Validate() error

type RedisLock

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

func NewRedisLock

func NewRedisLock(store *Redis, key string) *RedisLock

func (*RedisLock) Acquire

func (rl *RedisLock) Acquire() (bool, error)

func (*RedisLock) Release

func (rl *RedisLock) Release() (bool, error)

func (*RedisLock) SetExpire

func (rl *RedisLock) SetExpire(seconds int)

type RedisNode

type RedisNode interface {
	red.Cmdable
}

type ScriptCache

type ScriptCache struct {
	atomic.Value
}

func GetScriptCache

func GetScriptCache() *ScriptCache

func (*ScriptCache) GetSha

func (sc *ScriptCache) GetSha(script string) (string, bool)

func (*ScriptCache) SetSha

func (sc *ScriptCache) SetSha(script, sha string)

type Z

type Z = red.Z

Z represents sorted set member.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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