nosql

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConnectionFailed = errors.New("store connect fail.")
View Source
var ErrErrPoolExhausted = errors.New("connection poll exhausted.")
View Source
var ErrExecuteFailed = errors.New("store Execute Command fail.")
View Source
var ErrNegativeInt = errors.New("redis cluster: unexpected value for Uint64")
View Source
var ErrNil = errors.New("nil return")
View Source
var ErrWrongArgsNum = errors.New("args num error")
View Source
var ErrWrongType = errors.New("wrong type")

Functions

func Concurrency

func Concurrency(fns []Fn, maxIdle int64) error

func GetRedisStats

func GetRedisStats() []*redisStat

Types

type Fn

type Fn func() error

type HashStore

type HashStore interface {
	Reply
	// contains filtered or unexported methods
}

type HashZSetStore

type HashZSetStore interface {
	Reply
	// contains filtered or unexported methods
}

type KVHashStore

type KVHashStore interface {
	Reply
	// contains filtered or unexported methods
}

type KVStore

type KVStore interface {
	Reply
	// contains filtered or unexported methods
}

type ListStore

type ListStore interface {
	Reply
	// contains filtered or unexported methods
}

type Redis

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

func NewRedisCluster

func NewRedisCluster(addrs []string, password string) (*Redis, error)

func NewRedisClusterWithoutTimeout

func NewRedisClusterWithoutTimeout(addrs []string, password string) (*Redis, error)

func NewRedisSingle

func NewRedisSingle(addr string, password string) (*Redis, error)

func (*Redis) BLPop

func (r *Redis) BLPop(key string, timeout int) (interface{}, error)

func (*Redis) BRPop

func (r *Redis) BRPop(key string, timeout int) (interface{}, error)

func (*Redis) BRPopLPush

func (r *Redis) BRPopLPush(srcKey string, destKey string, timeout int) (interface{}, error)

为确保srcKey跟destKey映射到同一个slot,srcKey和destKey需要加上hash tag,如:{test}

func (*Redis) Bool

func (r *Redis) Bool(reply interface{}, err error) (bool, error)

func (*Redis) Bytes

func (r *Redis) Bytes(reply interface{}, err error) ([]byte, error)

func (*Redis) Del

func (r *Redis) Del(keys ...string) (int64, error)

func (*Redis) Eval

func (r *Redis) Eval(luaScript string, numberKeys int, keysArgs ...interface{}) (interface{}, error)

func (*Redis) EvalSha

func (r *Redis) EvalSha(sha1 string, numberKeys int, keysArgs ...interface{}) (interface{}, error)

func (*Redis) Exists

func (r *Redis) Exists(key string) (bool, error)

func (*Redis) Expire

func (r *Redis) Expire(key string, duration int64) (int64, error)

func (*Redis) ExpireAt

func (r *Redis) ExpireAt(key string, timestamp int64) (int64, error)

func (*Redis) Float64

func (r *Redis) Float64(reply interface{}, err error) (float64, error)

func (*Redis) GeoAdd

func (r *Redis) GeoAdd(key string, longitude, latitude float64, name string) error

新增或者更新一个地理位置

func (*Redis) GeoPos

func (r *Redis) GeoPos(key string, member string) (*redis.GeoPos, error)

func (*Redis) GeoRadius

func (r *Redis) GeoRadius(key string, longitude, latitude float64, radius float64, count int) ([]redis.GeoLocation, error)

查询某个地理位置指定半径以内的地点

func (*Redis) GeoRadiusByMember

func (r *Redis) GeoRadiusByMember(key string, member string, radius float64, count int) ([]redis.GeoLocation, error)

查询某个用户指定半径以内的地点

func (*Redis) Get

func (r *Redis) Get(key string) (interface{}, error)

func (*Redis) GetBit

func (r *Redis) GetBit(key string, offset int64) (int64, error)

func (*Redis) GetSet

func (r *Redis) GetSet(key string, value interface{}) (interface{}, error)

func (*Redis) HClear

func (r *Redis) HClear(key string) error

func (*Redis) HDel

func (r *Redis) HDel(key string, fields ...string) (int64, error)

func (*Redis) HExpire

func (r *Redis) HExpire(key string, duration int64) error

func (*Redis) HGet

func (r *Redis) HGet(key string, field string) (interface{}, error)

func (*Redis) HGetAll

func (r *Redis) HGetAll(key string) (map[string]interface{}, error)

func (*Redis) HIncrBy

func (r *Redis) HIncrBy(key, field string, delta int64) (int64, error)

func (*Redis) HKeys

func (r *Redis) HKeys(key string) ([]string, error)

func (*Redis) HLen

func (r *Redis) HLen(key string) (int64, error)

func (*Redis) HMGet

func (r *Redis) HMGet(key string, fields ...string) (interface{}, error)

func (*Redis) HMSet

func (r *Redis) HMSet(key string, kvs ...interface{}) error

func (*Redis) HSet

func (r *Redis) HSet(key string, field string, val interface{}) error

func (*Redis) HVals

func (r *Redis) HVals(key string) ([]interface{}, error)

func (*Redis) Incr

func (r *Redis) Incr(key string) (int64, error)

func (*Redis) IncrBy

func (r *Redis) IncrBy(key string, delta int64) (int64, error)

func (*Redis) Int

func (r *Redis) Int(reply interface{}, err error) (int, error)

func (*Redis) Int64

func (r *Redis) Int64(reply interface{}, err error) (int64, error)

func (*Redis) LLen

func (r *Redis) LLen(key string) (int64, error)

func (*Redis) LPop

func (r *Redis) LPop(key string) (interface{}, error)

func (*Redis) LPush

func (r *Redis) LPush(key string, value ...interface{}) error

func (*Redis) LRange

func (r *Redis) LRange(key string, start, stop int64) (interface{}, error)

func (*Redis) LRem

func (r *Redis) LRem(key string, count int, value interface{}) (int, error)

func (*Redis) LSet

func (r *Redis) LSet(key string, index int, value interface{}) error

func (*Redis) MGet

func (r *Redis) MGet(keys ...string) ([]interface{}, error)

func (*Redis) MSet

func (r *Redis) MSet(kvs map[string]interface{}) error

func (*Redis) MSetNX

func (r *Redis) MSetNX(kvs map[string]interface{}) (bool, error)

func (*Redis) RPop

func (r *Redis) RPop(key string) (interface{}, error)

func (*Redis) RPopLPush

func (r *Redis) RPopLPush(srcKey string, destKey string) (interface{}, error)

为确保srcKey跟destKey映射到同一个slot,srcKey和destKey需要加上hash tag,如:{test}

func (*Redis) RPush

func (r *Redis) RPush(key string, value ...interface{}) error

func (*Redis) SAdd

func (r *Redis) SAdd(key string, members ...interface{}) (int64, error)

func (*Redis) SIsMember

func (r *Redis) SIsMember(key string, member interface{}) (bool, error)

func (*Redis) SMembers

func (r *Redis) SMembers(key string) ([]string, error)

func (*Redis) SPop

func (r *Redis) SPop(key string) ([]byte, error)

func (*Redis) SRem

func (r *Redis) SRem(key string, members ...interface{}) (int64, error)

func (*Redis) ScriptLoad

func (r *Redis) ScriptLoad(luaScript string) (interface{}, error)

func (*Redis) Set

func (r *Redis) Set(key string, value interface{}) error

func (*Redis) SetBit

func (r *Redis) SetBit(key string, offset uint32, value int) (int, error)

func (*Redis) SetEx

func (r *Redis) SetEx(key string, value interface{}, timeout int64) error

func (*Redis) SetMaxActive

func (r *Redis) SetMaxActive(maxActive int)

func (*Redis) SetMaxIdle

func (r *Redis) SetMaxIdle(maxIdle int)

func (*Redis) SetNx

func (r *Redis) SetNx(key string, value interface{}) (int64, error)

func (*Redis) SetNxEx

func (r *Redis) SetNxEx(key string, value interface{}, timeout int64) error

nil表示成功,ErrNil表示数据库内已经存在这个key,其他表示数据库发生错误

func (*Redis) String

func (r *Redis) String(reply interface{}, err error) (string, error)

func (*Redis) Strings

func (r *Redis) Strings(reply interface{}, err error) ([]string, error)

func (*Redis) TTl

func (r *Redis) TTl(key string) (int64, error)

func (*Redis) Uint64

func (r *Redis) Uint64(reply interface{}, err error) (uint64, error)

func (*Redis) Values

func (r *Redis) Values(reply interface{}, err error) ([]interface{}, error)

func (*Redis) ZAdd

func (r *Redis) ZAdd(key string, kvs ...interface{}) (int64, error)

func (*Redis) ZClear

func (r *Redis) ZClear(key string) error

func (*Redis) ZExpire

func (r *Redis) ZExpire(key string, duration int64) error

func (*Redis) ZRange

func (r *Redis) ZRange(key string, min, max int64, withScores bool) (interface{}, error)

func (*Redis) ZRangeByScoreWithScore

func (r *Redis) ZRangeByScoreWithScore(key string, min, max int64) (map[string]int64, error)

func (*Redis) ZRem

func (r *Redis) ZRem(key string, members ...string) (int64, error)

func (*Redis) ZScore

func (r *Redis) ZScore(key string, member string) (float64, error)

type RedisStore

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

func NewRedisStore

func NewRedisStore(host string, port int, db int) (*RedisStore, error)

func NewRedisStoreWithoutTimeout

func NewRedisStoreWithoutTimeout(host string, port int, db int) (*RedisStore, error)

func (*RedisStore) BLPop

func (r *RedisStore) BLPop(key string, timeout int) (interface{}, error)

func (*RedisStore) BRPop

func (r *RedisStore) BRPop(key string, timeout int) (interface{}, error)

func (*RedisStore) BRPopLPush

func (r *RedisStore) BRPopLPush(srcKey string, destKey string, timeout int) (interface{}, error)

func (*RedisStore) Bool

func (r *RedisStore) Bool(reply interface{}, err error) (bool, error)

func (*RedisStore) Bytes

func (r *RedisStore) Bytes(reply interface{}, err error) ([]byte, error)

func (*RedisStore) Del

func (r *RedisStore) Del(keys ...string) (int64, error)

func (*RedisStore) Eval

func (r *RedisStore) Eval(luaScript string, numberKeys int, keysArgs ...interface{}) (interface{}, error)

func (*RedisStore) EvalSha

func (r *RedisStore) EvalSha(sha1 string, numberKeys int, keysArgs ...interface{}) (interface{}, error)

func (*RedisStore) Exists

func (r *RedisStore) Exists(key string) (bool, error)

func (*RedisStore) Expire

func (r *RedisStore) Expire(key string, duration int64) (int64, error)

func (*RedisStore) ExpireAt

func (r *RedisStore) ExpireAt(key string, timestamp int64) (int64, error)

func (*RedisStore) Float64

func (r *RedisStore) Float64(reply interface{}, err error) (float64, error)

func (*RedisStore) Get

func (r *RedisStore) Get(key string) (interface{}, error)

func (*RedisStore) GetBit

func (r *RedisStore) GetBit(key string, offset int64) (int64, error)

func (*RedisStore) GetPool

func (r *RedisStore) GetPool() *redis.Pool

func (*RedisStore) GetSet

func (r *RedisStore) GetSet(key string, value interface{}) (interface{}, error)

func (*RedisStore) HClear

func (r *RedisStore) HClear(key string) error

func (*RedisStore) HDel

func (r *RedisStore) HDel(key string, fields ...string) (int64, error)

func (*RedisStore) HExpire

func (r *RedisStore) HExpire(key string, duration int64) error

func (*RedisStore) HGet

func (r *RedisStore) HGet(key string, field string) (interface{}, error)

func (*RedisStore) HGetAll

func (r *RedisStore) HGetAll(key string) (map[string]interface{}, error)

func (*RedisStore) HIncrBy

func (r *RedisStore) HIncrBy(key, field string, delta int64) (int64, error)

func (*RedisStore) HKeys

func (r *RedisStore) HKeys(key string) ([]string, error)

func (*RedisStore) HLen

func (r *RedisStore) HLen(key string) (int64, error)

func (*RedisStore) HMGet

func (r *RedisStore) HMGet(key string, fields ...string) (interface{}, error)

func (*RedisStore) HMSet

func (r *RedisStore) HMSet(key string, kvs ...interface{}) error

func (*RedisStore) HSet

func (r *RedisStore) HSet(key string, field string, val interface{}) error

func (*RedisStore) HVals

func (r *RedisStore) HVals(key string) ([]interface{}, error)

func (*RedisStore) Incr

func (r *RedisStore) Incr(key string) (int64, error)

func (*RedisStore) IncrBy

func (r *RedisStore) IncrBy(key string, delta int64) (int64, error)

func (*RedisStore) Int

func (r *RedisStore) Int(reply interface{}, err error) (int, error)

func (*RedisStore) Int64

func (r *RedisStore) Int64(reply interface{}, err error) (int64, error)

func (*RedisStore) LLen

func (r *RedisStore) LLen(key string) (int64, error)

func (*RedisStore) LPop

func (r *RedisStore) LPop(key string) (interface{}, error)

func (*RedisStore) LPush

func (r *RedisStore) LPush(key string, value ...interface{}) error

func (*RedisStore) LRange

func (r *RedisStore) LRange(key string, start, stop int64) (interface{}, error)

func (*RedisStore) LRem

func (r *RedisStore) LRem(key string, count int, value interface{}) (int, error)

func (*RedisStore) LSet

func (r *RedisStore) LSet(key string, index int, value interface{}) error

func (*RedisStore) MGet

func (r *RedisStore) MGet(keys ...string) ([]interface{}, error)

func (*RedisStore) MSet

func (r *RedisStore) MSet(kvs map[string]interface{}) error

func (*RedisStore) MSetNX

func (r *RedisStore) MSetNX(kvs map[string]interface{}) (bool, error)

func (*RedisStore) RPop

func (r *RedisStore) RPop(key string) (interface{}, error)

func (*RedisStore) RPopLPush

func (r *RedisStore) RPopLPush(srcKey string, destKey string) (interface{}, error)

func (*RedisStore) RPush

func (r *RedisStore) RPush(key string, value ...interface{}) error

func (*RedisStore) SAdd

func (r *RedisStore) SAdd(key string, members ...interface{}) (int64, error)

func (*RedisStore) SIsMember

func (r *RedisStore) SIsMember(key string, member interface{}) (bool, error)

func (*RedisStore) SMembers

func (r *RedisStore) SMembers(key string) ([]string, error)

func (*RedisStore) SPop

func (r *RedisStore) SPop(key string) ([]byte, error)

func (*RedisStore) SRem

func (r *RedisStore) SRem(key string, members ...interface{}) (int64, error)

func (*RedisStore) ScriptLoad

func (r *RedisStore) ScriptLoad(luaScript string) (interface{}, error)

func (*RedisStore) Set

func (r *RedisStore) Set(key string, value interface{}) error

func (*RedisStore) SetBit

func (r *RedisStore) SetBit(key string, offset uint32, value int) (int, error)

func (*RedisStore) SetEx

func (r *RedisStore) SetEx(key string, value interface{}, timeout int64) error

func (*RedisStore) SetMaxActive

func (r *RedisStore) SetMaxActive(maxActive int)

func (*RedisStore) SetMaxIdle

func (r *RedisStore) SetMaxIdle(maxIdle int)

func (*RedisStore) SetNx

func (r *RedisStore) SetNx(key string, value interface{}) (int64, error)

func (*RedisStore) SetNxEx

func (r *RedisStore) SetNxEx(key string, value interface{}, timeout int64) error

nil表示成功,ErrNil表示数据库内已经存在这个key,其他表示数据库发生错误

func (*RedisStore) String

func (r *RedisStore) String(reply interface{}, err error) (string, error)

func (*RedisStore) Strings

func (r *RedisStore) Strings(reply interface{}, err error) ([]string, error)

func (*RedisStore) TTl

func (r *RedisStore) TTl(key string) (int64, error)

func (*RedisStore) Uint64

func (r *RedisStore) Uint64(reply interface{}, err error) (uint64, error)

func (*RedisStore) Values

func (r *RedisStore) Values(reply interface{}, err error) ([]interface{}, error)

func (*RedisStore) ZAdd

func (r *RedisStore) ZAdd(key string, kvs ...interface{}) (int64, error)

func (*RedisStore) ZClear

func (r *RedisStore) ZClear(key string) error

func (*RedisStore) ZExpire

func (r *RedisStore) ZExpire(key string, duration int64) error

func (*RedisStore) ZRange

func (r *RedisStore) ZRange(key string, min, max int64, withScores bool) (interface{}, error)

func (*RedisStore) ZRangeByScoreWithScore

func (r *RedisStore) ZRangeByScoreWithScore(key string, min, max int64) (map[string]int64, error)

func (*RedisStore) ZRem

func (r *RedisStore) ZRem(key string, members ...string) (int64, error)

type Reply

type Reply interface {
	Int(interface{}, error) (int, error)
	Int64(interface{}, error) (int64, error)
	Uint64(interface{}, error) (uint64, error)
	Float64(interface{}, error) (float64, error)
	Bool(interface{}, error) (bool, error)
	Bytes(interface{}, error) ([]byte, error)
	String(interface{}, error) (string, error)
	Strings(interface{}, error) ([]string, error)
	Values(interface{}, error) ([]interface{}, error)
}

type SetStore

type SetStore interface {
	Reply
	// contains filtered or unexported methods
}

type Store

type Store interface {
	Reply

	SetMaxIdle(int)
	SetMaxActive(int)
	// contains filtered or unexported methods
}

type ZSetStore

type ZSetStore interface {
	Reply
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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