Back to godoc.org
gitee.com/agent_iyyn/ssdb

Package ssdb

v1.0.1
Latest Go to latest

The latest major version is .

Published: May 28, 2020 | License: MIT | Module: gitee.com/agent_iyyn/ssdb

Index

type Client

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

Client connected client

func Connect

func Connect(opts ...Option) (*Client, error)

Connect connected client

func (*Client) Auth

func (c *Client) Auth(password string) error

Auth password Available since: 1.7.0.0 Authenticate the connection. Warning: The password is sent in plain-text over the network!

func (*Client) BitCount

func (c *Client) BitCount(key string, start, end int64) (int64, error)

BitCount Count the number of set bits (population counting) in a string. Like Redis's bitcount.

func (*Client) CountBit

func (c *Client) CountBit(key string, start, size int64) (int64, error)

CountBit Count the number of set bits (population counting) in a string. Like Redis's bitcount.

func (*Client) DBSize

func (c *Client) DBSize() (int64, error)

DBSize Return the approximate size of the database, in bytes. If compression is enabled, the size will be of the compressed data.

func (*Client) Del

func (c *Client) Del(key string) error

Del Delete specified key.

func (*Client) Do

func (c *Client) Do(args ...interface{}) (v Values, err0 error)

Do send and recv

func (*Client) Exists

func (c *Client) Exists(key string) (bool, error)

Exists Verify if the specified key exists.

func (*Client) Expire

func (c *Client) Expire(key string, ttl time.Duration) (bool, error)

Expire Set the time left to live in seconds, only for keys of KV type.

func (*Client) Get

func (c *Client) Get(key string) (Value, error)

Get Get the value related to the specified key.

func (*Client) GetBit

func (c *Client) GetBit(key string, offset int64) (bool, error)

GetBit Return a single bit out of a string.

func (*Client) GetConn

func (c *Client) GetConn() (*Conn, error)

GetConn get connection

func (*Client) GetSet

func (c *Client) GetSet(key string, value Value) (Value, error)

GetSet Sets a value and returns the previous entry at that key.

func (*Client) HClear

func (c *Client) HClear(name string) error

HClear Delete all keys in a hashmap.

func (*Client) HDel

func (c *Client) HDel(name, key string) (bool, error)

HDel Delete specified key of a hashmap. To delete the whole hashmap, use hclear.

func (*Client) HExists

func (c *Client) HExists(name, key string) (bool, error)

HExists Verify if the specified key exists in a hashmap.

func (*Client) HGet

func (c *Client) HGet(name, key string) (Value, error)

HGet Get the value related to the specified key of a hashmap

func (*Client) HGetAll

func (c *Client) HGetAll(name string) (map[string]Value, error)

HGetAll Returns the whole hash, as an array of strings indexed by strings.

func (*Client) HIncr

func (c *Client) HIncr(name, key string, num int64) (int64, error)

HIncr Since 1.7.0.1, *incr methods return error if value cannot be converted to integer. Increment the number stored at key in a hashmap by num. The num argument could be a negative integer. The old number is first converted to an integer before increment, assuming it was stored as literal integer.

func (*Client) HKeys

func (c *Client) HKeys(name, keyStart, keyEnd string, limit int64) ([]string, error)

HKeys List keys of a hashmap in range (keyStart, keyEnd]. ("", ""] means no range limit.

func (*Client) HKeysRangeAll

func (c *Client) HKeysRangeAll(name, keyStart, keyEnd string, limit int64, cb func(string) error) error

HKeysRangeAll Like hkeys, The whole range

func (*Client) HList

func (c *Client) HList(nameStart, nameEnd string, limit int64) ([]string, error)

HList List hashmap names in range (nameStart, nameEnd]. ("", ""] means no range limit. Refer to scan command for more information about how it work.

func (*Client) HListRangeAll

func (c *Client) HListRangeAll(nameStart, nameEnd string, limit int64, cb func(string) error) error

HListRangeAll Like hlist, The whole range

func (*Client) HRList

func (c *Client) HRList(nameStart, nameEnd string, limit int64) ([]string, error)

HRList Like hlist, but in reverse order.

func (*Client) HRListRangeAll

func (c *Client) HRListRangeAll(nameStart, nameEnd string, limit int64, cb func(string) error) error

HRListRangeAll Like hrlist, The whole range

func (*Client) HRScan

func (c *Client) HRScan(name string, keyStart, keyEnd string, limit int64) (map[string]Value, error)

HRScan Like hscan, but in reverse order.

func (*Client) HRScanRangeAll

func (c *Client) HRScanRangeAll(name string, keyStart, keyEnd string, limit int64, cb func(string, Value) error) error

HRScanRangeAll Like hrscan, The whole range

func (*Client) HScan

func (c *Client) HScan(name string, keyStart, keyEnd string, limit int64) (map[string]Value, error)

HScan List key-value pairs of a hashmap with keys in range (keyStart, keyEnd]. ("", ""] means no range limit. Refer to scan command for more information about how it work.

func (*Client) HScanRangeAll

func (c *Client) HScanRangeAll(name string, keyStart, keyEnd string, limit int64, cb func(string, Value) error) error

HScanRangeAll Like hscan, The whole range

func (*Client) HSet

func (c *Client) HSet(name, key string, value Value) (bool, error)

HSet Set the string value in argument as value of the key of a hashmap.

func (*Client) HSize

func (c *Client) HSize(name string) (int64, error)

HSize Return the number of key-value pairs in the hashmap.

func (*Client) Incr

func (c *Client) Incr(key string, num int64) (int64, error)

Incr Since 1.7.0.1, *incr methods return error if value cannot be converted to integer. Increment the number stored at key by num. The num argument could be a negative integer. The old number is first converted to an integer before increment, assuming it was stored as literal integer.

func (*Client) Info

func (c *Client) Info() ([]string, error)

Info Return information about the server.

func (*Client) Keys

func (c *Client) Keys(keyStart, keyEnd string, limit int64) ([]string, error)

Keys Refer to scan command for more information about how it work.

func (*Client) KeysRangeAll

func (c *Client) KeysRangeAll(keyStart, keyEnd string, limit int64, cb func(string) error) error

KeysRangeAll Like keys, The whole range

func (*Client) MultiDel

func (c *Client) MultiDel(key ...string) error

MultiDel Delete specified multiple keys.

func (*Client) MultiGet

func (c *Client) MultiGet(key ...string) (map[string]Value, error)

MultiGet Get the values related to the specified multiple keys

func (*Client) MultiHDel

func (c *Client) MultiHDel(name string, key ...string) error

MultiHDel Delete specified multiple keys in a hashmap.

func (*Client) MultiHGet

func (c *Client) MultiHGet(name string, key ...string) (map[string]Value, error)

MultiHGet Get the values related to the specified multiple keys of a hashmap.

func (*Client) MultiHSet

func (c *Client) MultiHSet(name string, kvs map[string]Value) error

MultiHSet Set multiple key-value pairs(kvs) of a hashmap in one method call.

func (*Client) MultiSet

func (c *Client) MultiSet(kvs map[string]Value) (err error)

MultiSet Set multiple key-value pairs(kvs) in one method call.

func (*Client) MultiZDel

func (c *Client) MultiZDel(name string, key ...string) error

MultiZDel Delete specified multiple keys of a zset.

func (*Client) MultiZGet

func (c *Client) MultiZGet(name string, key ...string) (map[string]int64, error)

MultiZGet Get the values related to the specified multiple keys of a zset.

func (*Client) MultiZSet

func (c *Client) MultiZSet(name string, kvs map[string]int64) error

MultiZSet Set multiple key-score pairs(kvs) of a zset in one method call.

func (*Client) PutConn

func (c *Client) PutConn(conn *Conn)

PutConn Put back the connection

func (*Client) QBack

func (c *Client) QBack(key string) (Value, error)

QBack Returns the last element of a queue.

func (*Client) QClear

func (c *Client) QClear(name string) error

QClear Clear the queue.

func (*Client) QFront

func (c *Client) QFront(key string) (Value, error)

QFront Returns the first element of a queue.

func (*Client) QGet

func (c *Client) QGet(key string, index int64) (Value, error)

QGet Returns the element a the specified index(position). 0 the first element, 1 the second ... -1 the last element.

func (*Client) QList

func (c *Client) QList(nameStart, nameEnd string, limit int64) ([]string, error)

QList List list/queue names in range (nameStart, nameEnd]. ("", ""] means no range limit. Refer to scan command for more information about how it work.

func (*Client) QListRangeAll

func (c *Client) QListRangeAll(nameStart, nameEnd string, limit int64, cb func(string) error) error

QListRangeAll Like qlist, The whole range

func (*Client) QPopBack

func (c *Client) QPopBack(name string, size int64) (Values, error)

QPopBack Pop out one or more elements from the tail of a queue.

func (*Client) QPopFront

func (c *Client) QPopFront(name string, size int64) (Values, error)

QPopFront Pop out one or more elements from the head of a queue.

func (*Client) QPushBack

func (c *Client) QPushBack(name string, item ...Value) (int64, error)

QPushBack Add an or more than one element to the end of the queue.

func (*Client) QPushFront

func (c *Client) QPushFront(name string, item ...Value) (int64, error)

QPushFront Add one or more than one element to the head of the queue.

func (*Client) QRList

func (c *Client) QRList(nameStart, nameEnd string, limit int64) ([]string, error)

QRList Like qlist, but in reverse order.

func (*Client) QRListRangeAll

func (c *Client) QRListRangeAll(nameStart, nameEnd string, limit int64, cb func(string) error) error

QRListRangeAll Like qrlist, The whole range

func (*Client) QRange

func (c *Client) QRange(name string, offset, limit int) (Values, error)

QRange Returns a portion of elements from the queue at the specified range [offset, offset + limit].

func (*Client) QSet

func (c *Client) QSet(key string, index int64, value Value) error

QSet Sets the list element at index to value. An error is returned for out of range indexes.

func (*Client) QSize

func (c *Client) QSize(name string) (int64, error)

QSize Returns the number of items in the queue.

func (*Client) QSlice

func (c *Client) QSlice(name string, begin, end int) (Values, error)

QSlice Returns a portion of elements from the queue at the specified range [begin, end]. begin and end could be negative.

func (*Client) QTrimBack

func (c *Client) QTrimBack(name string, size int) (int64, error)

QTrimBack Remove multi elements from the tail of a queue.

func (*Client) QTrimFront

func (c *Client) QTrimFront(name string, size int) (int64, error)

QTrimFront Remove multi elements from the head of a queue.

func (*Client) RKeys

func (c *Client) RKeys(keyStart, keyEnd string, limit int64) ([]string, error)

RKeys Since 1.9.0, Like keys, but in reverse order.

func (*Client) RKeysRangeAll

func (c *Client) RKeysRangeAll(keyStart, keyEnd string, limit int64, cb func(string) error) error

RKeysRangeAll Like rkeys, The whole range

func (*Client) RScan

func (c *Client) RScan(keyStart, keyEnd string, limit int64) (map[string]Value, error)

RScan Like scan, but in reverse order.

func (*Client) RScanRangeAll

func (c *Client) RScanRangeAll(keyStart, keyEnd string, limit int64, cb func(string, Value) error) error

RScanRangeAll Like rscan, The whole range

func (*Client) Scan

func (c *Client) Scan(keyStart, keyEnd string, limit int64) (map[string]Value, error)

Scan List key-value pairs with keys in range (keyStart, keyEnd]. ("", ""] means no range limit. This command can do wildchar * like search, but only prefix search, and the * char must never occur in keyStart and keyEnd!

func (*Client) ScanRangeAll

func (c *Client) ScanRangeAll(keyStart, keyEnd string, limit int64, cb func(string, Value) error) error

ScanRangeAll Like scan, The whole range

func (*Client) Set

func (c *Client) Set(key string, value Value) error

Set Set the value of the key.

func (*Client) SetBit

func (c *Client) SetBit(key string, offset int64, value bool) (bool, error)

SetBit Changes a single bit of a string. The string is auto expanded.

func (*Client) SetNX

func (c *Client) SetNX(key string, value Value) (bool, error)

SetNX Set the string value in argument as value of the key if and only if the key doesn't exist.

func (*Client) SetX

func (c *Client) SetX(key string, value Value, ttl time.Duration) error

SetX Set the value of the key, with a time to live. Unlike Redis, the ttl will not be remove when later set the same key!

func (*Client) StrLen

func (c *Client) StrLen(key string) (int64, error)

StrLen Return the number of bytes of a string.

func (*Client) SubStr

func (c *Client) SubStr(key string, start int64, size int64) (string, error)

SubStr Return part of a string,

func (*Client) TTL

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

TTL Returns the time left to live in seconds, only for keys of KV type.

func (*Client) ZAvg

func (c *Client) ZAvg(name string, scoreStart, scoreEnd int64) (int64, error)

ZAvg Returns the average of elements of the sorted set stored at the specified key which have scores in the range [start,end].

func (*Client) ZClear

func (c *Client) ZClear(name string) error

ZClear Delete all keys in a zset.

func (*Client) ZCount

func (c *Client) ZCount(name string, start, end string) (int64, error)

ZCount Returns the number of elements of the sorted set stored at the specified key which have scores in the range [start,end].

func (*Client) ZDel

func (c *Client) ZDel(name, key string) error

ZDel Delete specified key of a zset.

func (*Client) ZExists

func (c *Client) ZExists(name, key string) (bool, error)

ZExists Verify if the specified key exists in a zset.

func (*Client) ZGet

func (c *Client) ZGet(name, key string) (int64, error)

ZGet Get the score related to the specified key of a zset

func (*Client) ZIncr

func (c *Client) ZIncr(name string, key string, num int64) (int64, error)

ZIncr Increment the number stored at key in a zset by num.

func (*Client) ZKeys

func (c *Client) ZKeys(name string, keyStart string, scoreStart, scoreEnd int64, limit int64) ([]string, error)

ZKeys List keys in a zset.

func (*Client) ZKeysRangAll

func (c *Client) ZKeysRangAll(name string, keyStart string, scoreStart, scoreEnd int64, limit int64, cb func(string) error) error

ZKeysRangAll Like zkeys, The whole range

func (*Client) ZList

func (c *Client) ZList(nameStart, nameEnd string, limit int64) ([]string, error)

ZList List zset names in range (nameStart, nameEnd]. Refer to scan command for more information about how it work.

func (*Client) ZListRangAll

func (c *Client) ZListRangAll(nameStart, nameEnd string, limit int64, cb func(string) error) error

ZListRangAll Like zlist, The whole range

func (*Client) ZPopBack

func (c *Client) ZPopBack(name string, limit int64) (map[string]int64, error)

ZPopBack Since 1.9.0, Delete and return limit element(s) from back of the zset.

func (*Client) ZPopFront

func (c *Client) ZPopFront(name string, limit int64) (map[string]int64, error)

ZPopFront Since 1.9.0, Delete and return limit element(s) from front of the zset.

func (*Client) ZRList

func (c *Client) ZRList(nameStart, nameEnd string, limit int64) ([]string, error)

ZRList List zset names in range (nameStart, nameEnd], in reverse order.

func (*Client) ZRListRangAll

func (c *Client) ZRListRangAll(nameStart, nameEnd string, limit int64, cb func(string) error) error

ZRListRangAll Like zrlist, The whole range

func (*Client) ZRRange

func (c *Client) ZRRange(name string, offset, limit int64) (map[string]int64, error)

ZRRange Returns a range of key-score pairs by index range [offset, offset + limit), in reverse order.

func (*Client) ZRRank

func (c *Client) ZRRank(name, key string) (int64, error)

ZRRank Returns the rank(index) of a given key in the specified sorted set, in reverse order.

func (*Client) ZRScan

func (c *Client) ZRScan(name string, keyStart string, scoreStart, scoreEnd int64, limit int64) (map[string]int64, error)

ZRScan List key-score pairs of a zset, in reverse order.

func (*Client) ZRange

func (c *Client) ZRange(name string, offset, limit int64) (map[string]int64, error)

ZRange Returns a range of key-score pairs by index range [offset, offset + limit).

func (*Client) ZRank

func (c *Client) ZRank(name, key string) (int64, error)

ZRank Returns the rank(index) of a given key in the specified sorted set.

func (*Client) ZRemRangeByRank

func (c *Client) ZRemRangeByRank(name string, start, end int64) error

ZRemRangeByRank Delete the elements of the zset which have rank in the range [start,end].

func (*Client) ZRemRangeByScore

func (c *Client) ZRemRangeByScore(name string, start, end int64) error

ZRemRangeByScore Delete the elements of the zset which have score in the range [start,end].

func (*Client) ZScan

func (c *Client) ZScan(name string, keyStart string, scoreStart, scoreEnd int64, limit int64) (map[string]int64, error)

ZScan List key-score pairs where key-score in range (keyStart+scoreStart, scoreEnd]. Refer to scan command for more information about how it work.

func (*Client) ZSet

func (c *Client) ZSet(name, key string, score int64) error

ZSet Set the score of the key of a zset.

func (*Client) ZSize

func (c *Client) ZSize(name string) (int64, error)

ZSize Return the number of pairs of a zset.

func (*Client) ZSum

func (c *Client) ZSum(name string, scoreStart, scoreEnd int64) (int64, error)

ZSum Returns the sum of elements of the sorted set stored at the specified key which have scores in the range [start,end].

type Conn

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

Conn a SSDB connection

func (*Conn) Close

func (c *Conn) Close() error

Close Connection

func (*Conn) Recv

func (c *Conn) Recv() (Values, error)

Recv receive data

func (*Conn) Send

func (c *Conn) Send(args Values) error

Send send data

type Option

type Option func(c *Client)

Option is a function that configures a Client

func Addr

func Addr(addr string) Option

Addr 127.0.0.1:8888

func Auth

func Auth(auth string) Option

Auth password

func DialHandler

func DialHandler(df func(addr string) (net.Conn, error)) Option

DialHandler proxy

func URL

func URL(u string) Option

URL ssdb://127.0.0.1:8888[?Auth=password]

type Value

type Value []byte

Value return val

func NewValue

func NewValue(arg interface{}) Value

func (Value) Bool

func (v Value) Bool() bool

Bool get bool

func (Value) Bytes

func (v Value) Bytes() []byte

Bytes get bytes

func (Value) Duration

func (v Value) Duration() time.Duration

Duration get time.Duration

func (Value) Equal

func (v Value) Equal(y Value) bool

Equal value equal

func (Value) Float

func (v Value) Float() float64

Float get float

func (Value) Int

func (v Value) Int() int64

Int get int

func (Value) IsEmpty

func (v Value) IsEmpty() bool

IsEmpty is empty

func (Value) String

func (v Value) String() string

String

func (Value) Uint

func (v Value) Uint() uint64

Uint get uint

func (Value) UnJson

func (v Value) UnJson(obj interface{}) error

Bytes get unjson

type Values

type Values []Value

Values Value Slice

func NewValues

func NewValues(arg []interface{}) Values

func (Values) MapStringInt

func (v Values) MapStringInt() map[string]int64

MapStringInt get map[string]int64

func (Values) MapStringValue

func (v Values) MapStringValue() map[string]Value

MapStringValue get map[string]Value

func (Values) Strings

func (v Values) Strings() []string

Strings get []string

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier