ledisdb: github.com/siddontang/ledisdb/ledis Index | Files

package ledis

import "github.com/siddontang/ledisdb/ledis"

Package ledis is a high performance embedded NoSQL.

Ledis supports various data structure like kv, list, hash and zset like redis.

Other features include replication, data with a limited time-to-live.

Usage

First create a ledis instance before use:

l := ledis.Open(cfg)

cfg is a Config instance which contains configuration for ledis use, like DataDir (root directory for ledis working to store data).

After you create a ledis instance, you can select a DB to store you data:

db, _ := l.Select(0)

DB must be selected by a index, ledis supports only 16 databases, so the index range is [0-15].

KV

KV is the most basic ledis type like any other key-value database.

err := db.Set(key, value)
value, err := db.Get(key)

List

List is simply lists of values, sorted by insertion order. You can push or pop value on the list head (left) or tail (right).

err := db.LPush(key, value1)
err := db.RPush(key, value2)
value1, err := db.LPop(key)
value2, err := db.RPop(key)

Hash

Hash is a map between fields and values.

n, err := db.HSet(key, field1, value1)
n, err := db.HSet(key, field2, value2)
value1, err := db.HGet(key, field1)
value2, err := db.HGet(key, field2)

ZSet

ZSet is a sorted collections of values. Every member of zset is associated with score, a int64 value which used to sort, from smallest to greatest score. Members are unique, but score may be same.

n, err := db.ZAdd(key, ScorePair{score1, member1}, ScorePair{score2, member2})
ay, err := db.ZRangeByScore(key, minScore, maxScore, 0, -1)

Index

Package Files

batch.go const.go doc.go dump.go event.go ledis.go ledis_db.go migrate.go replication.go scan.go sort.go t_hash.go t_kv.go t_list.go t_set.go t_ttl.go t_zset.go util.go

Constants

const (
    KVName   = "KV"
    ListName = "LIST"
    HashName = "HASH"
    SetName  = "SET"
    ZSetName = "ZSET"
)

For different type name

const (
    NoneType   byte = 0
    KVType     byte = 1
    HashType   byte = 2
    HSizeType  byte = 3
    ListType   byte = 4
    LMetaType  byte = 5
    ZSetType   byte = 6
    ZSizeType  byte = 7
    ZScoreType byte = 8
    // BitType     byte = 9
    // BitMetaType byte = 10
    SetType   byte = 11
    SSizeType byte = 12

    /*
    	I make a big mistake about TTL time key format and have to use a new one (change 101 to 103).
    	You must run the ledis-upgrade-ttl to upgrade db.
    */
    ObsoleteExpTimeType byte = 101
    ExpMetaType         byte = 102
    ExpTimeType         byte = 103

    MetaType byte = 201
)

for backend store

const (
    // max allowed databases
    MaxDatabases int = 10240

    // max key size
    MaxKeySize int = 1024

    // max hash field size
    MaxHashFieldSize int = 1024

    // max zset member size
    MaxZSetMemberSize int = 1024

    // max set member size
    MaxSetMemberSize int = 1024

    // max value size
    MaxValueSize int = 1024 * 1024 * 1024
)

For different const size configuration

const (
    BitAND = "and"
    BitOR  = "or"
    BitXOR = "xor"
    BitNot = "not"
)

For bit operation

const (
    UnionType byte = 51
    DiffType  byte = 52
    InterType byte = 53
)

For set operation type.

const (
    MinScore     int64 = -1<<63 + 1
    MaxScore     int64 = 1<<63 - 1
    InvalidScore int64 = -1 << 63

    AggregateSum byte = 0
    AggregateMin byte = 1
    AggregateMax byte = 2
)

For zset const.

const Version = "0.5"

Version is for version

Variables

var (
    ErrScoreMiss     = errors.New("zset score miss")
    ErrWriteInROnly  = errors.New("write not support in readonly mode")
    ErrRplInRDWR     = errors.New("replication not support in read write mode")
    ErrRplNotSupport = errors.New("replication not support")
)

For different common errors

var (
    ErrLogMissed = errors.New("log is pured in server")
)

For replication error.

var TypeName = map[byte]string{
    KVType:     "kv",
    HashType:   "hash",
    HSizeType:  "hsize",
    ListType:   "list",
    LMetaType:  "lmeta",
    ZSetType:   "zset",
    ZSizeType:  "zsize",
    ZScoreType: "zscore",

    SetType:     "set",
    SSizeType:   "ssize",
    ExpTimeType: "exptime",
    ExpMetaType: "expmeta",
}

TypeName is the map of type -> name

func AsyncNotify Uses

func AsyncNotify(ch chan struct{})

AsyncNotify notices the channel.

func Int64 Uses

func Int64(v []byte, err error) (int64, error)

Int64 gets 64 integer with the little endian format.

func PutInt64 Uses

func PutInt64(v int64) []byte

PutInt64 puts the 64 integer.

func StrInt32 Uses

func StrInt32(v []byte, err error) (int32, error)

StrInt32 gets the 32 integer with string format.

func StrInt64 Uses

func StrInt64(v []byte, err error) (int64, error)

StrInt64 gets the 64 integer with string format.

func StrInt8 Uses

func StrInt8(v []byte, err error) (int8, error)

StrInt8 ets the 8 integer with string format.

func StrUint64 Uses

func StrUint64(v []byte, err error) (uint64, error)

StrUint64 gets the unsigned 64 integer with string format.

func Uint64 Uses

func Uint64(v []byte, err error) (uint64, error)

Uint64 gets unsigned 64 integer.

type DB Uses

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

DB is the database.

func (*DB) Append Uses

func (db *DB) Append(key []byte, value []byte) (int64, error)

Append appends the value to the data.

func (*DB) BLPop Uses

func (db *DB) BLPop(keys [][]byte, timeout time.Duration) ([]interface{}, error)

BLPop pops the list with block way.

func (*DB) BRPop Uses

func (db *DB) BRPop(keys [][]byte, timeout time.Duration) ([]interface{}, error)

BRPop bpops the list with block way.

func (*DB) BitCount Uses

func (db *DB) BitCount(key []byte, start int, end int) (int64, error)

BitCount returns the bit count of data.

func (*DB) BitOP Uses

func (db *DB) BitOP(op string, destKey []byte, srcKeys ...[]byte) (int64, error)

BitOP does the bit operations in data.

func (*DB) BitPos Uses

func (db *DB) BitPos(key []byte, on int, start int, end int) (int64, error)

BitPos returns the pos of the data.

func (*DB) Decr Uses

func (db *DB) Decr(key []byte) (int64, error)

Decr decreases the data.

func (*DB) DecrBy Uses

func (db *DB) DecrBy(key []byte, decrement int64) (int64, error)

DecrBy decreases the data by decrement.

func (*DB) Del Uses

func (db *DB) Del(keys ...[]byte) (int64, error)

Del deletes the data.

func (*DB) Dump Uses

func (db *DB) Dump(key []byte) ([]byte, error)

Dump dumps the KV value of key

func (*DB) Exists Uses

func (db *DB) Exists(key []byte) (int64, error)

Exists check data exists or not.

func (*DB) Expire Uses

func (db *DB) Expire(key []byte, duration int64) (int64, error)

Expire expires the data.

func (*DB) ExpireAt Uses

func (db *DB) ExpireAt(key []byte, when int64) (int64, error)

ExpireAt expires the data at when.

func (*DB) FlushAll Uses

func (db *DB) FlushAll() (drop int64, err error)

FlushAll flushes the data.

func (*DB) Get Uses

func (db *DB) Get(key []byte) ([]byte, error)

Get gets the value.

func (*DB) GetBit Uses

func (db *DB) GetBit(key []byte, offset int) (int64, error)

GetBit gets the bit of data at offset.

func (*DB) GetRange Uses

func (db *DB) GetRange(key []byte, start int, end int) ([]byte, error)

GetRange gets the range of the data.

func (*DB) GetSet Uses

func (db *DB) GetSet(key []byte, value []byte) ([]byte, error)

GetSet gets the value and sets new value.

func (*DB) GetSlice Uses

func (db *DB) GetSlice(key []byte) (store.Slice, error)

GetSlice gets the slice of the data.

func (*DB) HClear Uses

func (db *DB) HClear(key []byte) (int64, error)

HClear clears the data.

func (*DB) HDel Uses

func (db *DB) HDel(key []byte, args ...[]byte) (int64, error)

HDel deletes the fields.

func (*DB) HDump Uses

func (db *DB) HDump(key []byte) ([]byte, error)

HDump dumps the hash value of key

func (*DB) HExpire Uses

func (db *DB) HExpire(key []byte, duration int64) (int64, error)

HExpire expires the data with duration.

func (*DB) HExpireAt Uses

func (db *DB) HExpireAt(key []byte, when int64) (int64, error)

HExpireAt expires the data at time when.

func (*DB) HGet Uses

func (db *DB) HGet(key []byte, field []byte) ([]byte, error)

HGet gets the value of the field.

func (*DB) HGetAll Uses

func (db *DB) HGetAll(key []byte) ([]FVPair, error)

HGetAll returns all field-values.

func (*DB) HIncrBy Uses

func (db *DB) HIncrBy(key []byte, field []byte, delta int64) (int64, error)

HIncrBy increases the value of field by delta.

func (*DB) HKeyExists Uses

func (db *DB) HKeyExists(key []byte) (int64, error)

HKeyExists checks whether data exists or not.

func (*DB) HKeys Uses

func (db *DB) HKeys(key []byte) ([][]byte, error)

HKeys returns the all fields.

func (*DB) HLen Uses

func (db *DB) HLen(key []byte) (int64, error)

HLen returns the lengh of hash.

func (*DB) HMclear Uses

func (db *DB) HMclear(keys ...[]byte) (int64, error)

HMclear cleans multi data.

func (*DB) HMget Uses

func (db *DB) HMget(key []byte, args ...[]byte) ([][]byte, error)

HMget gets multi values of fields

func (*DB) HMset Uses

func (db *DB) HMset(key []byte, args ...FVPair) error

HMset sets multi field-values.

func (*DB) HPersist Uses

func (db *DB) HPersist(key []byte) (int64, error)

HPersist removes the TTL of data.

func (*DB) HRevScan Uses

func (db *DB) HRevScan(key []byte, cursor []byte, count int, inclusive bool, match string) ([]FVPair, error)

HRevScan reversed scans data for hash.

func (*DB) HScan Uses

func (db *DB) HScan(key []byte, cursor []byte, count int, inclusive bool, match string) ([]FVPair, error)

HScan scans data for hash.

func (*DB) HSet Uses

func (db *DB) HSet(key []byte, field []byte, value []byte) (int64, error)

HSet sets the field with value of key.

func (*DB) HTTL Uses

func (db *DB) HTTL(key []byte) (int64, error)

HTTL gets the TTL of data.

func (*DB) HValues Uses

func (db *DB) HValues(key []byte) ([][]byte, error)

HValues returns all values

func (*DB) Incr Uses

func (db *DB) Incr(key []byte) (int64, error)

Incr increases the data.

func (*DB) IncrBy Uses

func (db *DB) IncrBy(key []byte, increment int64) (int64, error)

IncrBy increases the data by increment.

func (*DB) Index Uses

func (db *DB) Index() int

Index gets the index of database.

func (*DB) LClear Uses

func (db *DB) LClear(key []byte) (int64, error)

LClear clears the list.

func (*DB) LDump Uses

func (db *DB) LDump(key []byte) ([]byte, error)

LDump dumps the list value of key

func (*DB) LExpire Uses

func (db *DB) LExpire(key []byte, duration int64) (int64, error)

LExpire expires the list.

func (*DB) LExpireAt Uses

func (db *DB) LExpireAt(key []byte, when int64) (int64, error)

LExpireAt expires the list at when.

func (*DB) LIndex Uses

func (db *DB) LIndex(key []byte, index int32) ([]byte, error)

LIndex returns the value at index.

func (*DB) LKeyExists Uses

func (db *DB) LKeyExists(key []byte) (int64, error)

LKeyExists check list existed or not.

func (*DB) LLen Uses

func (db *DB) LLen(key []byte) (int64, error)

LLen gets the length of the list.

func (*DB) LMclear Uses

func (db *DB) LMclear(keys ...[]byte) (int64, error)

LMclear clears multi lists.

func (*DB) LPersist Uses

func (db *DB) LPersist(key []byte) (int64, error)

LPersist removes the TTL of list.

func (*DB) LPop Uses

func (db *DB) LPop(key []byte) ([]byte, error)

LPop pops the value.

func (*DB) LPush Uses

func (db *DB) LPush(key []byte, args ...[]byte) (int64, error)

LPush push the value to the list.

func (*DB) LRange Uses

func (db *DB) LRange(key []byte, start int32, stop int32) ([][]byte, error)

LRange gets the value of list at range.

func (*DB) LSet Uses

func (db *DB) LSet(key []byte, index int32, value []byte) error

LSet sets the value at index.

func (*DB) LTTL Uses

func (db *DB) LTTL(key []byte) (int64, error)

LTTL gets the TTL of list.

func (*DB) LTrim Uses

func (db *DB) LTrim(key []byte, start, stop int64) error

LTrim trims the value from start to stop.

func (*DB) LTrimBack Uses

func (db *DB) LTrimBack(key []byte, trimSize int32) (int32, error)

LTrimBack trims the value from back.

func (*DB) LTrimFront Uses

func (db *DB) LTrimFront(key []byte, trimSize int32) (int32, error)

LTrimFront trims the value from top.

func (*DB) MGet Uses

func (db *DB) MGet(keys ...[]byte) ([][]byte, error)

MGet gets multi data.

func (*DB) MSet Uses

func (db *DB) MSet(args ...KVPair) error

MSet sets multi data.

func (*DB) Persist Uses

func (db *DB) Persist(key []byte) (int64, error)

Persist removes the TTL of the data.

func (*DB) RPop Uses

func (db *DB) RPop(key []byte) ([]byte, error)

RPop rpops the value.

func (*DB) RPush Uses

func (db *DB) RPush(key []byte, args ...[]byte) (int64, error)

RPush rpushs the value .

func (*DB) Restore Uses

func (db *DB) Restore(key []byte, ttl int64, data []byte) error

Restore restores a key into database.

func (*DB) RevScan Uses

func (db *DB) RevScan(dataType DataType, cursor []byte, count int, inclusive bool, match string) ([][]byte, error)

RevScan scans the data reversed. if inclusive is true, revscan range (-inf, cursor] else (inf, cursor)

func (*DB) SAdd Uses

func (db *DB) SAdd(key []byte, args ...[]byte) (int64, error)

SAdd adds the value to the set.

func (*DB) SCard Uses

func (db *DB) SCard(key []byte) (int64, error)

SCard gets the size of set.

func (*DB) SClear Uses

func (db *DB) SClear(key []byte) (int64, error)

SClear clears the set.

func (*DB) SDiff Uses

func (db *DB) SDiff(keys ...[]byte) ([][]byte, error)

SDiff gets the different of sets.

func (*DB) SDiffStore Uses

func (db *DB) SDiffStore(dstKey []byte, keys ...[]byte) (int64, error)

SDiffStore gets the different of sets and stores to dest set.

func (*DB) SDump Uses

func (db *DB) SDump(key []byte) ([]byte, error)

SDump dumps the set value of key

func (*DB) SExpire Uses

func (db *DB) SExpire(key []byte, duration int64) (int64, error)

SExpire expries the set.

func (*DB) SExpireAt Uses

func (db *DB) SExpireAt(key []byte, when int64) (int64, error)

SExpireAt expires the set at when.

func (*DB) SInter Uses

func (db *DB) SInter(keys ...[]byte) ([][]byte, error)

SInter intersects the sets.

func (*DB) SInterStore Uses

func (db *DB) SInterStore(dstKey []byte, keys ...[]byte) (int64, error)

SInterStore intersects the sets and stores to dest set.

func (*DB) SIsMember Uses

func (db *DB) SIsMember(key []byte, member []byte) (int64, error)

SIsMember checks member in set.

func (*DB) SKeyExists Uses

func (db *DB) SKeyExists(key []byte) (int64, error)

SKeyExists checks whether set existed or not.

func (*DB) SMclear Uses

func (db *DB) SMclear(keys ...[]byte) (int64, error)

SMclear clears multi sets.

func (*DB) SMembers Uses

func (db *DB) SMembers(key []byte) ([][]byte, error)

SMembers gets members of set.

func (*DB) SPersist Uses

func (db *DB) SPersist(key []byte) (int64, error)

SPersist removes the TTL of set.

func (*DB) SRem Uses

func (db *DB) SRem(key []byte, args ...[]byte) (int64, error)

SRem removes the members of set.

func (*DB) SRevScan Uses

func (db *DB) SRevScan(key []byte, cursor []byte, count int, inclusive bool, match string) ([][]byte, error)

SRevScan scans data reversed for set.

func (*DB) SScan Uses

func (db *DB) SScan(key []byte, cursor []byte, count int, inclusive bool, match string) ([][]byte, error)

SScan scans data for set.

func (*DB) STTL Uses

func (db *DB) STTL(key []byte) (int64, error)

STTL gets the TTL of set.

func (*DB) SUnion Uses

func (db *DB) SUnion(keys ...[]byte) ([][]byte, error)

SUnion unions the sets.

func (*DB) SUnionStore Uses

func (db *DB) SUnionStore(dstKey []byte, keys ...[]byte) (int64, error)

SUnionStore unions the sets and stores to the dest set.

func (*DB) Scan Uses

func (db *DB) Scan(dataType DataType, cursor []byte, count int, inclusive bool, match string) ([][]byte, error)

Scan scans the data. If inclusive is true, scan range [cursor, inf) else (cursor, inf)

func (*DB) Set Uses

func (db *DB) Set(key []byte, value []byte) error

Set sets the data.

func (*DB) SetBit Uses

func (db *DB) SetBit(key []byte, offset int, on int) (int64, error)

SetBit sets the bit to the data.

func (*DB) SetEX Uses

func (db *DB) SetEX(key []byte, duration int64, value []byte) error

SetEX sets the data with a TTL.

func (*DB) SetNX Uses

func (db *DB) SetNX(key []byte, value []byte) (int64, error)

SetNX sets the data if not existed.

func (*DB) SetRange Uses

func (db *DB) SetRange(key []byte, offset int, value []byte) (int64, error)

SetRange sets the data with new value from offset.

func (*DB) StrLen Uses

func (db *DB) StrLen(key []byte) (int64, error)

StrLen returns the length of the data.

func (*DB) TTL Uses

func (db *DB) TTL(key []byte) (int64, error)

TTL returns the TTL of the data.

func (*DB) XLSort Uses

func (db *DB) XLSort(key []byte, offset int, size int, alpha bool, desc bool, sortBy []byte, sortGet [][]byte) ([][]byte, error)

XLSort sorts list.

func (*DB) XSSort Uses

func (db *DB) XSSort(key []byte, offset int, size int, alpha bool, desc bool, sortBy []byte, sortGet [][]byte) ([][]byte, error)

XSSort sorts set.

func (*DB) XZSort Uses

func (db *DB) XZSort(key []byte, offset int, size int, alpha bool, desc bool, sortBy []byte, sortGet [][]byte) ([][]byte, error)

XZSort sorts zset.

func (*DB) ZAdd Uses

func (db *DB) ZAdd(key []byte, args ...ScorePair) (int64, error)

ZAdd add the members.

func (*DB) ZCard Uses

func (db *DB) ZCard(key []byte) (int64, error)

ZCard gets the size of the zset.

func (*DB) ZClear Uses

func (db *DB) ZClear(key []byte) (int64, error)

ZClear clears the zset.

func (*DB) ZCount Uses

func (db *DB) ZCount(key []byte, min int64, max int64) (int64, error)

ZCount gets the number of score in [min, max]

func (*DB) ZDump Uses

func (db *DB) ZDump(key []byte) ([]byte, error)

ZDump dumps the zset value of key

func (*DB) ZExpire Uses

func (db *DB) ZExpire(key []byte, duration int64) (int64, error)

ZExpire expires the zset.

func (*DB) ZExpireAt Uses

func (db *DB) ZExpireAt(key []byte, when int64) (int64, error)

ZExpireAt expires the zset at when.

func (*DB) ZIncrBy Uses

func (db *DB) ZIncrBy(key []byte, delta int64, member []byte) (int64, error)

ZIncrBy increases the score of member with delta.

func (*DB) ZInterStore Uses

func (db *DB) ZInterStore(destKey []byte, srcKeys [][]byte, weights []int64, aggregate byte) (int64, error)

ZInterStore intersects the zsets and stores to dest zset.

func (*DB) ZKeyExists Uses

func (db *DB) ZKeyExists(key []byte) (int64, error)

ZKeyExists checks zset existed or not.

func (*DB) ZLexCount Uses

func (db *DB) ZLexCount(key []byte, min []byte, max []byte, rangeType uint8) (int64, error)

ZLexCount gets the count of zset lexicographically.

func (*DB) ZMclear Uses

func (db *DB) ZMclear(keys ...[]byte) (int64, error)

ZMclear clears multi zsets.

func (*DB) ZPersist Uses

func (db *DB) ZPersist(key []byte) (int64, error)

ZPersist removes the TTL of zset.

func (*DB) ZRange Uses

func (db *DB) ZRange(key []byte, start int, stop int) ([]ScorePair, error)

ZRange gets the members from start to stop.

func (*DB) ZRangeByLex Uses

func (db *DB) ZRangeByLex(key []byte, min []byte, max []byte, rangeType uint8, offset int, count int) ([][]byte, error)

ZRangeByLex scans the zset lexicographically

func (*DB) ZRangeByScore Uses

func (db *DB) ZRangeByScore(key []byte, min int64, max int64,
    offset int, count int) ([]ScorePair, error)

ZRangeByScore gets the data with score in min and max. min and max must be inclusive if no limit, set offset = 0 and count = -1

func (*DB) ZRangeByScoreGeneric Uses

func (db *DB) ZRangeByScoreGeneric(key []byte, min int64, max int64,
    offset int, count int, reverse bool) ([]ScorePair, error)

ZRangeByScoreGeneric is a generic function to scan zset with score. min and max must be inclusive if no limit, set offset = 0 and count = -1

func (*DB) ZRangeGeneric Uses

func (db *DB) ZRangeGeneric(key []byte, start int, stop int, reverse bool) ([]ScorePair, error)

ZRangeGeneric is a generic function for scan zset.

func (*DB) ZRank Uses

func (db *DB) ZRank(key []byte, member []byte) (int64, error)

ZRank gets the rank of member.

func (*DB) ZRem Uses

func (db *DB) ZRem(key []byte, members ...[]byte) (int64, error)

ZRem removes members

func (*DB) ZRemRangeByLex Uses

func (db *DB) ZRemRangeByLex(key []byte, min []byte, max []byte, rangeType uint8) (int64, error)

ZRemRangeByLex remvoes members in [min, max] lexicographically

func (*DB) ZRemRangeByRank Uses

func (db *DB) ZRemRangeByRank(key []byte, start int, stop int) (int64, error)

ZRemRangeByRank removes the member at range from start to stop.

func (*DB) ZRemRangeByScore Uses

func (db *DB) ZRemRangeByScore(key []byte, min int64, max int64) (int64, error)

ZRemRangeByScore removes the data with score at [min, max]

func (*DB) ZRevRange Uses

func (db *DB) ZRevRange(key []byte, start int, stop int) ([]ScorePair, error)

ZRevRange gets the data reversed.

func (*DB) ZRevRangeByScore Uses

func (db *DB) ZRevRangeByScore(key []byte, min int64, max int64, offset int, count int) ([]ScorePair, error)

ZRevRangeByScore gets the data with score at [min, max] min and max must be inclusive if no limit, set offset = 0 and count = -1

func (*DB) ZRevRank Uses

func (db *DB) ZRevRank(key []byte, member []byte) (int64, error)

ZRevRank gets the rank of member reversed.

func (*DB) ZRevScan Uses

func (db *DB) ZRevScan(key []byte, cursor []byte, count int, inclusive bool, match string) ([]ScorePair, error)

ZRevScan scans data reversed for zset.

func (*DB) ZScan Uses

func (db *DB) ZScan(key []byte, cursor []byte, count int, inclusive bool, match string) ([]ScorePair, error)

ZScan scans data for zset.

func (*DB) ZScore Uses

func (db *DB) ZScore(key []byte, member []byte) (int64, error)

ZScore gets the score of member.

func (*DB) ZTTL Uses

func (db *DB) ZTTL(key []byte) (int64, error)

ZTTL gets the TTL of zset.

func (*DB) ZUnionStore Uses

func (db *DB) ZUnionStore(destKey []byte, srcKeys [][]byte, weights []int64, aggregate byte) (int64, error)

ZUnionStore unions the zsets and stores to dest zset.

type DataType Uses

type DataType byte

DataType is defined for the different types

const (
    KV  DataType = iota
    LIST
    HASH
    SET
    ZSET
)

for out use

func (DataType) String Uses

func (d DataType) String() string

type DumpHead Uses

type DumpHead struct {
    CommitID uint64
}

DumpHead is the head of a dump.

func (*DumpHead) Read Uses

func (h *DumpHead) Read(r io.Reader) error

Read reads meta from the Reader.

func (*DumpHead) Write Uses

func (h *DumpHead) Write(w io.Writer) error

Write writes meta to the Writer

type FVPair Uses

type FVPair struct {
    Field []byte
    Value []byte
}

FVPair is the pair of field and value.

type KVPair Uses

type KVPair struct {
    Key   []byte
    Value []byte
}

KVPair is the pair of key-value.

type Ledis Uses

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

Ledis is the core structure to handle the database.

func Open Uses

func Open(cfg *config.Config) (*Ledis, error)

Open opens the Ledis with a config.

func (*Ledis) AddNewLogEventHandler Uses

func (l *Ledis) AddNewLogEventHandler(h NewLogEventHandler) error

AddNewLogEventHandler adds the handler for the new log event

func (*Ledis) Close Uses

func (l *Ledis) Close()

Close closes the Ledis.

func (*Ledis) CompactStore Uses

func (l *Ledis) CompactStore() error

CompactStore compacts the backend storage.

func (*Ledis) Dump Uses

func (l *Ledis) Dump(w io.Writer) error

Dump dumps data to the Writer.

func (*Ledis) DumpFile Uses

func (l *Ledis) DumpFile(path string) error

DumpFile dumps data to the file

func (*Ledis) FlushAll Uses

func (l *Ledis) FlushAll() error

FlushAll will clear all data and replication logs

func (*Ledis) IsReadOnly Uses

func (l *Ledis) IsReadOnly() bool

IsReadOnly returns whether Ledis is read only or not.

func (*Ledis) LoadDump Uses

func (l *Ledis) LoadDump(r io.Reader) (*DumpHead, error)

LoadDump clears all data and loads dump file to db

func (*Ledis) LoadDumpFile Uses

func (l *Ledis) LoadDumpFile(path string) (*DumpHead, error)

LoadDumpFile clears all data and loads dump file to db

func (*Ledis) ReadLogsTo Uses

func (l *Ledis) ReadLogsTo(startLogID uint64, w io.Writer) (n int, nextLogID uint64, err error)

ReadLogsTo reads logs and write to the Writer.

func (*Ledis) ReadLogsToTimeout Uses

func (l *Ledis) ReadLogsToTimeout(startLogID uint64, w io.Writer, timeout int, quitCh chan struct{}) (n int, nextLogID uint64, err error)

ReadLogsToTimeout tries to read events, if no events read, tres to wait the new event singal until timeout seconds

func (*Ledis) ReplicationStat Uses

func (l *Ledis) ReplicationStat() (*rpl.Stat, error)

ReplicationStat returns the statistics of repliaciton.

func (*Ledis) ReplicationUsed Uses

func (l *Ledis) ReplicationUsed() bool

ReplicationUsed returns whether replication is used or not.

func (*Ledis) Select Uses

func (l *Ledis) Select(index int) (*DB, error)

Select chooses a database.

func (*Ledis) StoreLogsFromData Uses

func (l *Ledis) StoreLogsFromData(data []byte) error

StoreLogsFromData stores logs from data.

func (*Ledis) StoreLogsFromReader Uses

func (l *Ledis) StoreLogsFromReader(rb io.Reader) error

StoreLogsFromReader stores logs from the Reader

func (*Ledis) StoreStat Uses

func (l *Ledis) StoreStat() *store.Stat

StoreStat returns the statistics.

func (*Ledis) WaitReplication Uses

func (l *Ledis) WaitReplication() error

WaitReplication waits replication done

type Limit Uses

type Limit struct {
    Offset int
    Size   int
}

Limit is for sort.

type NewLogEventHandler Uses

type NewLogEventHandler func(rl *rpl.Log)

NewLogEventHandler is the handler to handle new log event.

type ScorePair Uses

type ScorePair struct {
    Score  int64
    Member []byte
}

ScorePair is the pair of score and member.

Package ledis imports 25 packages (graph) and is imported by 231 packages. Updated 2018-10-29. Refresh now. Tools for package owners.