ssdb

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: MIT Imports: 10 Imported by: 0

README

SSDB client for golang

Derive from the official client is more in line with the golang style and supports connection pooling.

Go Report Card GoDoc GitHub license

example

package main

import (
	"fmt"

	"github.com/wzshiming/ssdb"
)

func main() {
	db, err := ssdb.Connect(
		ssdb.Addr("127.0.0.1:8888"),
		ssdb.Auth("password"),
		// or ssdb.URL("ssdb://127.0.0.1:8888?Auth=password"),
	)
	if err != nil {
		fmt.Println(err)
		return
	}

	err = db.Set("a", "xxx")
	if err != nil {
		fmt.Println(err)
		return
	}

	val, err := db.Get("a")
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(val)

	err = db.Del("a")
	if err != nil {
		fmt.Println(err)
		return
	}

	val, err = db.Get("a")
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(val)

	err = db.ZSet("z", "a", 3)
	if err != nil {
		fmt.Println(err)
		return
	}

	err = db.MultiZSet("z", map[string]int64{
		"b": -1,
		"c": 5,
		"d": 3,
	})
	if err != nil {
		fmt.Println(err)
		return
	}

	resp, err := db.ZRange("z", 0, 10)
	if err != nil {
		fmt.Println(err)
		return
	}

	for k, v := range resp {
		fmt.Printf("  %v : %v\n", k, v)
	}

	return
}

API Support

Official Documents
API Documents

  • Server
    • auth password - Authenticate the connection.
    • dbsize - Return the approximate size of the database.
    • flushdb [type] - Delete all data in ssdb server.
    • info [opt] - Return the information of server.
    • slaveof id host port [auth last_seq last_key] - Start a replication slave.
  • IP Filter
  • Key Value
    • set key value - Set the value of the key.
    • setx key value ttl - Set the value of the key, with a time to live.
    • setnx key value - Set the string value in argument as value of the key only if the key doesn"t exist.
    • expire key ttl - Set the time left to live in seconds, only for keys of KV type.
    • ttl key - Returns the time left to live in seconds, only for keys of KV type.
    • get key - Get the value related to the specified key
    • getset key value - Sets a value and returns the previous entry at that key.
    • del key - Delete specified key.
    • incr key [num] - Increment the number stored at key by num.
    • exists key - Verify if the specified key exists.
    • getbit key offset - Return a single bit out of a string.
    • setbit key offset val - Changes a single bit of a string. The string is auto expanded.
    • bitcount key [start] [end] - Count the number of set bits (population counting) in part of a string.
    • countbit key start size - Count the number of set bits (population counting) in part of a string.
    • substr key start size - Return part of a string.
    • strlen key - Return the number of bytes of a string.
    • keys key_start key_end limit - List keys in range (key_start, key_end].
    • rkeys key_start key_end limit - List keys in range (key_start, key_end], in reverse order.
    • scan key_start key_end limit - List key-value pairs with keys in range (key_start, key_end].
    • rscan key_start key_end limit - List key-value pairs with keys in range (key_start, key_end], in reverse order.
    • multi_set key1 value1 key2 value2 ... - Set multiple key-value pairs(kvs) in one method call.
    • multi_get key1 key2 ... - Get the values related to the specified multiple keys
    • multi_del key1 key2 ... - Delete specified multiple keys.
  • Hashmap
    • hset name key value - Set the string value in argument as value of the key of a hashmap.
    • hget name key - Get the value related to the specified key of a hashmap
    • hdel name key - Delete specified key in a hashmap.
    • hincr name key [num] - Increment the number stored at key in a hashmap by num
    • hexists name key - Verify if the specified key exists in a hashmap.
    • hsize name - Return the number of key-value pairs in the hashmap.
    • hlist name_start name_end limit - List hashmap names in range (name_start, name_end].
    • hrlist name_start name_end limit - List hashmap names in range (name_start, name_end].
    • hkeys name key_start key_end - List keys of a hashmap in range (key_start, key_end].
    • hgetall name - Returns the whole hash, as an array of strings indexed by strings.
    • hscan name key_start key_end limit - List key-value pairs of a hashmap with keys in range (key_start, key_end].
    • hrscan name key_start key_end limit - List key-value pairs with keys in range (key_start, key_end], in reverse order.
    • hclear name - Delete all keys in a hashmap.
    • multi_hset name key1 value1 key2 value2 ... - Set multiple key-value pairs(kvs) of a hashmap in one method call.
    • multi_hget name key1 key2 ... - Get the values related to the specified multiple keys of a hashmap.
    • multi_hdel name key1 key2 ... - Delete specified multiple keys in a hashmap.
  • Sorted Set
    • zset name key score - Set the score of the key of a zset.
    • zget name key - Get the score related to the specified key of a zset
    • zdel name key - Delete specified key of a zset.
    • zincr name key num - Increment the number stored at key in a zset by num.
    • zexists name key - Verify if the specified key exists in a zset.
    • zsize name - Return the number of pairs of a zset.
    • zlist name_start name_end limit - List zset names in range (name_start, name_end].
    • zrlist name_start name_end limit - List zset names in range (name_start, name_end], in reverse order.
    • zkeys name key_start score_start score_end limit - List keys in a zset.
    • zscan name key_start score_start score_end limit - List key-score pairs where key-score in range (key_start+score_start, score_end].
    • zrscan name key_start score_start score_end limit - List key-score pairs of a zset, in reverse order. See method zkeys().
    • zrank name key - Returns the rank(index) of a given key in the specified sorted set.
    • zrrank name key - Returns the rank(index) of a given key in the specified sorted set, in reverse order.
    • zrange name offset limit - Returns a range of key-score pairs by index range [offset, offset + limit).
    • zrrange name offset limit - Returns a range of key-score pairs by index range [offset, offset + limit), in reverse order.
    • zclear name - Delete all keys in a zset.
    • zcount name score_start score_end - Returns the number of elements of the sorted set stored at the specified key which have scores in the range [score_start,score_end].
    • zsum name score_start score_end - Returns the sum of elements of the sorted set stored at the specified key which have scores in the range [score_start,score_end].
    • zavg name score_start score_end - Returns the average of elements of the sorted set stored at the specified key which have scores in the range [score_start,score_end].
    • zremrangebyrank name start end - Delete the elements of the zset which have rank in the range [start,end].
    • zremrangebyscore name start end - Delete the elements of the zset which have score in the range [start,end].
    • zpop_front name limit - Delete limit elements from front of the zset.
    • zpop_back name limit - Delete limit elements from back of the zset.
    • multi_zset name key1 score1 key2 score2 ... - Set multiple key-score pairs(kvs) of a zset in one method call.
    • multi_zget name key1 key2 ... - Get the values related to the specified multiple keys of a zset.
    • multi_zdel name key1 key2 ... - Delete specified multiple keys of a zset.
  • List
    • qpush_front name item1 item2 ... - Adds one or more than one element to the head of the queue.
    • qpush_back name item1 item2 ... - Adds an or more than one element to the end of the queue.
    • qpop_front name size - Pop out one or more elements from the head of a queue.
    • qpop_back name size - Pop out one or more elements from the tail of a queue.
    • qpush name item1 item2 ... - Alias of qpush_back.
    • qpop name size - Alias of qpop_front.
    • qfront name - Returns the first element of a queue.
    • qback name - Returns the last element of a queue.
    • qsize name - Returns the number of items in the queue.
    • qclear name - Clear the queue.
    • qget name index - Returns the element a the specified index(position).
    • qset name index val - Description
    • qrange name offset limit - Returns a portion of elements from the queue at the specified range [offset, offset + limit].
    • qslice name begin end - Returns a portion of elements from the queue at the specified range [begin, end].
    • qtrim_front name size - Remove multi elements from the head of a queue.
    • qtrim_back name size - Remove multi elements from the tail of a queue.
    • qlist name_start name_end limit - List list/queue names in range (name_start, name_end].
    • qrlist name_start name_end limit - List list/queue names in range (name_start, name_end], in reverse order.

License

Pouch is licensed under the MIT License. See LICENSE for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 added in v1.0.1

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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