xdb

package
v0.0.0-...-5ea3ca1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const Nil = redis.Nil

Variables

This section is empty.

Functions

func AddKK

func AddKK(h string) string

func Close

func Close()

func Conn

func Conn() *redis.Conn

func ConnClose

func ConnClose(c *redis.Conn)

func Del

func Del(k string) error

删除指定的一批keys, 如果删除中的某些key不存在,则直接忽略。 你无法通过返回值来判断被删除的 key 是否存在.

func Exists

func Exists(k string) (bool, error)

func Expire

func Expire(k string, ttl int) (bool, error)

1 如果成功设置过期时间。 0 如果key不存在或者不能设置过期时间。

func ExpireAt

func ExpireAt(k string, tm time.Time) (bool, error)

ExpireAt 的作用和 Expire,都用于为 key 设置生存时间。 不同在于 ExpireAt 命令接受的时间参数是 Unix 时间戳 Unix timestamp 。 time.Now().Add(time.Hour) time.Now().Add(900 * time.Millisecond)

func FlushDB

func FlushDB()

func Get

func Get(k string) (value interface{}, err error)

返回key的value。

如果key不存在,返回特殊值nil。
如果key的value不是string,就返回错误,因为GET只处理string类型的values。

返回值

simple-string-reply:key对应的value,或者nil(key不存在时)

func GetStr

func GetStr(k string) (string, error)

func GetTo

func GetTo(k string, v interface{}) error

func HClear

func HClear(h string) error

func HDel

func HDel(h, k string) error

func HExists

func HExists(h, k string) (bool, error)

func HExistsNotErr

func HExistsNotErr(h, k string) bool

func HGet

func HGet(h, k string) (v interface{}, err error)

func HGetAll

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

func HGetAllMapStrInt

func HGetAllMapStrInt(h string) (map[string]int, error)

func HGetAllOriginal

func HGetAllOriginal(h string) (map[string]string, error)

func HGetF64

func HGetF64(h, k string) (v float64, err error)

func HGetInt

func HGetInt(h, k string) (v int, err error)

func HGetInt64

func HGetInt64(h, k string) (v int64, err error)

func HGetNotUnpack

func HGetNotUnpack(h, k string) (string, error)

func HGetStr

func HGetStr(h, k string) (v string, err error)

func HGetTo

func HGetTo(h, k string, v interface{}) error

func HIncr

func HIncr(h, k string) (int, error)

func HIncrBy

func HIncrBy(h, k string, v int) (int, error)

func HIncrByFloat

func HIncrByFloat(key, field string, incr float64) (float64, error)

func HIncrGet

func HIncrGet(h, k string) (int, error)

func HIncrId

func HIncrId(h, k string, digit int) (int, error)

func HIncrSet

func HIncrSet(h, k string, v int) (int, error)

func HKeys

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

func HKeysPrefix

func HKeysPrefix(h, prefix string) ([]string, error)

func HLen

func HLen(h string) (int, error)

func HScan

func HScan(h string, cursor uint64, match string, count int, onlyKeys ...bool) (map[string]interface{}, uint64, error)

func HScanMatch

func HScanMatch(h string, match string) (map[string]interface{}, error)

func HScanNotUnpack

func HScanNotUnpack(h string, cursor uint64, prefix string, count int) ([]string, uint64, error)

func HScanPrefix

func HScanPrefix(h string, prefix string) (map[string]interface{}, error)

func HSet

func HSet(h, k string, v interface{}) error

func HSetEncrypt

func HSetEncrypt(h, k string, v interface{}, key string) error

func HValues

func HValues(h string) ([]interface{}, error)

func HValuesByPrefix

func HValuesByPrefix(h, prefix string) ([]interface{}, error)

func HValuesByPrefixStr

func HValuesByPrefixStr(h, prefix string) ([]string, error)

func HValuesNotUnpack

func HValuesNotUnpack(h string) ([]string, error)

func HValuesTo

func HValuesTo(h string, p interface{}) error

func HValuesToByPrefix

func HValuesToByPrefix(h, prefix string, p interface{}) error

func HkeysPrefixIteratorOriginal

func HkeysPrefixIteratorOriginal(h, prefix string) ([]string, error)

func HmDel

func HmDel(h string, ks []string) error

func HmDelByPrefix

func HmDelByPrefix(h string, prefix string) error

func HmGet

func HmGet(h string, ks []string) ([]interface{}, error)

func HmGetTo

func HmGetTo(h string, ks []string, p interface{}) error

func HmSet

func HmSet(h string, kvm map[string]interface{}) error

func HmSetEncrypt

func HmSetEncrypt(h string, kvm map[string]interface{}, key string) error

func HmSetOriginal

func HmSetOriginal(h string, kvm map[string]interface{}) error

func Incr

func Incr(k string) (int, error)

对存储在指定key的数值执行原子的加1操作。

func IncrBy

func IncrBy(k string, v int) (int, error)

将key对应的数字加decrement。 1. 如果key不存在,操作之前,key就会被置为0。 2. 如果key的value类型错误或是个不能表示成数字 返回错误: ERR value is not an integer or out of range

func Info

func Info() string

func Keys

func Keys(pattern string) ([]string, error)

查找所有符合给定模式pattern(正则表达式)的 key 。 Warning: 生产环境使用 KEYS 命令需要非常小心。 在大的数据库上执行命令会影响性能, 不要在你的代码中使用 KEYS 如果你需要一个寻找键空间中的key子集,考虑使用SCAN 或 sets

支持的匹配模式 patterns:

h?llo 匹配 hello, hallo 和 hxllo
h*llo 匹配 hllo 和 heeeello
h[ae]llo 匹配 hello 和 hallo, 不匹配 hillo
h[^e]llo 匹配 hallo, hbllo, … 不匹配 hello
h[a-b]llo 匹配 hallo 和 hbllo
使用 \ 转义你想匹配的特殊字符。

func KeysByPrefix

func KeysByPrefix(prefix string) ([]string, error)

func KeysIterator

func KeysIterator(prefix string) ([]string, error)

包含 hash

func LIndex

func LIndex(key string, index int) (string, error)

func LInsertAfter

func LInsertAfter(key string, pivot, value interface{}) (int, error)

func LInsertBefore

func LInsertBefore(key string, pivot, value interface{}) (int, error)

func LLen

func LLen(key string) (int, error)

func LPop

func LPop(key string) (string, error)

func LPush

func LPush(key string, value interface{}) error

func LPushX

func LPushX(key string, value interface{}) error

func LRange

func LRange(key string, start, stop int) ([]string, error)

func LRem

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

func LSet

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

func LTrim

func LTrim(key string, start, stop int) error

func MDel

func MDel(s []string) error

func MDelByPrefix

func MDelByPrefix(prefix string) error

func MGet

func MGet(ks []string) ([]interface{}, error)

func MSet

func MSet(kvm map[string]interface{}) error

func Open

func Open(HostPort ...string) error

func RPop

func RPop(key string) (string, error)

func RPopLPush

func RPopLPush(src, dst string) (string, error)

func RPush

func RPush(key string, value interface{}) error

func RPushX

func RPushX(key string, value interface{}) error

func Scan

func Scan(match string) ([]string, error)

func Set

func Set(k string, v interface{}) error

func SetX

func SetX(k string, v interface{}, ttl int) error

func TTL

func TTL(k string) (time.Duration, error)

如果key不存在或者已过期,返回 -2*time.Nanosecond 如果key存在并且没有设置过期时间(永久有效),返回 -1*time.Nanosecond

func Type

func Type(k string) (string, error)

Type > string hash list set 如果key不存在或者已过期,返回 -2*time.Nanosecond 如果key存在并且没有设置过期时间(永久有效),返回 -1*time.Nanosecond

func VersionHashName

func VersionHashName(hashName string) string

VersionHashName "%v_%v", hashName, "Version"

Types

This section is empty.

Jump to

Keyboard shortcuts

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