Documentation ¶
Index ¶
- Variables
- type DBConfig
- type LazyDB
- func (db *LazyDB) Append(key, value []byte) error
- func (db *LazyDB) Begin(txType TxType) (*Tx, error)
- func (db *LazyDB) Close() error
- func (db *LazyDB) Count() int
- func (db *LazyDB) Decr(key []byte) (int64, error)
- func (db *LazyDB) DecrBy(key []byte, decr int64) (int64, error)
- func (db *LazyDB) Delete(key []byte) error
- func (db *LazyDB) Expire(key []byte, duration time.Duration) error
- func (db *LazyDB) Get(key []byte) ([]byte, error)
- func (db *LazyDB) GetDel(key []byte) ([]byte, error)
- func (db *LazyDB) GetRange(key []byte, start, end int) ([]byte, error)
- func (db *LazyDB) GetStrsKeys() ([][]byte, error)
- func (db *LazyDB) HDel(key []byte, fields ...[]byte) (int, error)
- func (db *LazyDB) HExists(key []byte, field []byte) (bool, error)
- func (db *LazyDB) HGet(key, field []byte) ([]byte, error)
- func (db *LazyDB) HGetAll(key []byte) ([][]byte, error)
- func (db *LazyDB) HKeys(key []byte) ([][]byte, error)
- func (db *LazyDB) HLen(key []byte) int
- func (db *LazyDB) HMGet(key []byte, fields ...[]byte) ([][]byte, error)
- func (db *LazyDB) HSet(key []byte, args ...[]byte) error
- func (db *LazyDB) HSetNX(key, field, value []byte) error
- func (db *LazyDB) HVals(key []byte) ([][]byte, error)
- func (db *LazyDB) Incr(key []byte) (int64, error)
- func (db *LazyDB) IncrBy(key []byte, incr int64) (int64, error)
- func (db *LazyDB) IsClosed() bool
- func (db *LazyDB) LIndex(key []byte, index int) (value []byte, err error)
- func (db *LazyDB) LLen(key []byte) (len int)
- func (db *LazyDB) LMove(sourceKey []byte, distKey []byte, sourceIsLeft bool, distIsLeft bool) (val []byte, err error)
- func (db *LazyDB) LPop(key []byte) (value []byte, err error)
- func (db *LazyDB) LPush(key []byte, args ...[]byte) (err error)
- func (db *LazyDB) LPushX(key []byte, args ...[]byte) (err error)
- func (db *LazyDB) LRange(key []byte, start int, stop int) (value [][]byte, err error)
- func (db *LazyDB) LSet(key []byte, index int, value []byte) (err error)
- func (db *LazyDB) MGet(keys [][]byte) ([][]byte, error)
- func (db *LazyDB) MSet(args ...[]byte) error
- func (db *LazyDB) MSetNX(args ...[]byte) error
- func (db *LazyDB) Merge(typ valueType, targetFid uint32, gcRatio float64) error
- func (db *LazyDB) Persist(key []byte) error
- func (db *LazyDB) RPop(key []byte) (value []byte, err error)
- func (db *LazyDB) RPush(key []byte, args ...[]byte) (err error)
- func (db *LazyDB) RPushX(key []byte, args ...[]byte) (err error)
- func (db *LazyDB) SAdd(key []byte, members ...[]byte) error
- func (db *LazyDB) SIsMember(key, member []byte) bool
- func (db *LazyDB) SMembers(key []byte) ([][]byte, error)
- func (db *LazyDB) SPop(key []byte, num uint) ([][]byte, error)
- func (db *LazyDB) SRem(key []byte, members ...[]byte) error
- func (db *LazyDB) Scan(prefix []byte, pattern string, count int) ([][]byte, error)
- func (db *LazyDB) Set(key, value []byte) error
- func (db *LazyDB) SetEX(key, value []byte, duration time.Duration) error
- func (db *LazyDB) SetNX(key, value []byte) error
- func (db *LazyDB) StrLen(key []byte) int
- func (db *LazyDB) Sync() error
- func (db *LazyDB) TTL(key []byte) (int64, error)
- func (db *LazyDB) ZAdd(key []byte, args ...[]byte) error
- func (db *LazyDB) ZCard(key []byte) int
- func (db *LazyDB) ZIncrBy(key []byte, increment float64, member []byte) (float64, error)
- func (db *LazyDB) ZPopMax(key []byte) ([]byte, float64, error)
- func (db *LazyDB) ZPopMaxWithCount(key []byte, count int) (members [][]byte, scores []float64, err error)
- func (db *LazyDB) ZPopMin(key []byte) ([]byte, float64, error)
- func (db *LazyDB) ZPopMinWithCount(key []byte, count int) (members [][]byte, scores []float64, err error)
- func (db *LazyDB) ZRange(key []byte, start, stop int) (members [][]byte)
- func (db *LazyDB) ZRangeWithScores(key []byte, start, stop int) (members [][]byte, scores []float64)
- func (db *LazyDB) ZRank(key, member []byte) (rank int, err error)
- func (db *LazyDB) ZRem(key []byte, members ...[]byte) (number int, err error)
- func (db *LazyDB) ZRevRange(key []byte, start, stop int) (members [][]byte)
- func (db *LazyDB) ZRevRangeWithScores(key []byte, start, stop int) (members [][]byte, scores []float64)
- func (db *LazyDB) ZRevRank(key, member []byte) (rank int, err error)
- func (db *LazyDB) ZScore(key, member []byte) (score float64, err error)
- type MutexFids
- type MutexLogFile
- type Node
- type Tx
- type TxStatus
- type TxType
- type Value
- type ValuePos
- type ZSetIndex
Constants ¶
This section is empty.
Variables ¶
var ( ErrKeyNotFound = errors.New("key not found") ErrLogFileNotExist = errors.New("log file is not exist") ErrOpenLogFile = errors.New("open Log file error") ErrWrongIndex = errors.New("index is out of range") ErrDatabaseClosed = errors.New("database is closed") )
var ( ErrWrongValueType = errors.New("value is not an integer") ErrIntegerOverFlow = errors.New("integer overflow") )
var ( ErrTxClosed = errors.New("transaction is closed") ErrTxCommittingRollback = errors.New("transaction rollback while committing") )
var ( ErrZSetKeyNotExist = errors.New("zset key not exist") ErrZSetMemberNotExist = errors.New("zset member not exist") )
var (
ErrDiscardNoSpace = errors.New("not enough space can be allocated for the discard file")
)
var (
ErrInvalidParam = errors.New("parameters are invalid")
)
Functions ¶
This section is empty.
Types ¶
type DBConfig ¶
type DBConfig struct { DBPath string // Directory path for storing log files on disk. HashIndexShardCount int64 // default 32 MaxLogFileSize int64 // Max capacity of a log file. LogFileMergeInterval time.Duration // Max time interval for merging log files. // IOType // Only support FileIO at the moment IOType logfile.IOType // DiscardBufferSize a channel will be created to send the older entry size when a key updated or deleted. // Entry size will be saved in the discard file, recording the invalid size in a log file, and be used when log file gc is running. // This option represents the size of that channel. // If you got errors like `send discard chan fail`, you can increase this option to avoid it. DiscardBufferSize int // LogFileGCRatio if discarded data in log file exceeds this ratio, it can be picked up for compaction(garbage collection) // And if there are many files reached the ratio, we will pick the highest one by one. // The recommended ratio is 0.5, half of the file can be compacted. // Default value is 0.5. LogFileGCRatio float64 }
func DefaultDBConfig ¶
type LazyDB ¶
type LazyDB struct {
// contains filtered or unexported fields
}
func (*LazyDB) Append ¶
Append appends the value at the end of the old value if key already exists. It will be similar to Set if key does not exist.
func (*LazyDB) Decr ¶
Decr decrements the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation. It returns ErrWrongKeyType error if the value is not integer type. Also, it returns ErrIntegerOverflow error if the value exceeds after decrementing the value.
func (*LazyDB) DecrBy ¶
DecrBy decrements the number stored at key by decr. If the key doesn't exist, it is set to 0 before performing the operation. It returns ErrWrongKeyType error if the value is not integer type. Also, it returns ErrIntegerOverflow error if the value exceeds after decrementing the value.
func (*LazyDB) Get ¶
Get get the value of key. If the key does not exist the error ErrKeyNotFound is returned.
func (*LazyDB) GetDel ¶
GetDel gets the value of the key and deletes the key. This method is similar to Get method. It also deletes the key if it exists.
func (*LazyDB) GetRange ¶
GetRange returns the substring of the string value stored at key, determined by the offsets start and end.
func (*LazyDB) GetStrsKeys ¶
GetStrsKeys get all stored keys of type String.
func (*LazyDB) HExists ¶
HExists returns whether the field exists in the hash stored at key Returns false either key or field is not exist
func (*LazyDB) HGet ¶
HGet returns value of given key and field. It will return empty if key is not found.
func (*LazyDB) HMGet ¶
HMGet returns multiple values by given fields It will skip those fields which don't exist.
func (*LazyDB) HSet ¶
HSet is used to insert a field value pair for key. If key does not exist, a new key will be created. If the field already exist, the value will be updated. Multiple field-value pair could be inserted in the format of "key field1 value1 field2 value2"
func (*LazyDB) HSetNX ¶
HSetNX sets the given value if the key-field pair does not exist. Creates a new hash if key is not exist.
func (*LazyDB) Incr ¶
Incr increments the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation. It returns ErrWrongKeyType error if the value is not integer type. Also, it returns ErrIntegerOverflow error if the value exceeds after incrementing the value.
func (*LazyDB) IncrBy ¶
IncrBy increments the number stored at key by incr. If the key doesn't exist, it is set to 0 before performing the operation. It returns ErrWrongKeyType error if the value is not integer type. Also, it returns ErrIntegerOverflow error if the value exceeds after incrementing the value.
func (*LazyDB) MGet ¶
MGet get the values of all specified keys. If the key that does not hold a string value or does not exist, nil is returned.
func (*LazyDB) MSet ¶
MSet is multiple set command. Parameter order should be like "key", "value", "key", "value", ...
func (*LazyDB) MSetNX ¶
MSetNX sets given keys to their respective values. MSetNX will not perform any operation at all even if just a single key already exists.
func (*LazyDB) SIsMember ¶
SIsMember returns if the argument is the one value of the set stored at key.
func (*LazyDB) Scan ¶
Scan iterates over all keys of type String and finds its value. Parameter prefix will match key`s prefix, and pattern is a regular expression that also matchs the key. Parameter count limits the number of keys, a nil slice will be returned if count is not a positive number. The returned values will be a mixed data of keys and values, like [key1, value1, key2, value2, etc...].
func (*LazyDB) Set ¶
Set set key to hold the string value. If key already holds a value, it is overwritten. Any previous time to live associated with the key is discarded on successful Set operation.
func (*LazyDB) SetEX ¶
SetEX set key to hold the string value and set key to timeout after the given duration.
func (*LazyDB) SetNX ¶
SetNX sets the key-value pair if it is not exist. It returns nil if the key already exists.
func (*LazyDB) StrLen ¶
StrLen returns the length of the string value stored at key. If the key doesn't exist, it returns 0.
func (*LazyDB) ZAdd ¶
ZAdd adds the specified member with the specified score to the sorted set stored at key.
func (*LazyDB) ZCard ¶
ZCard returns the sorted set cardinality (number of elements) of the sorted set stored at key.
func (*LazyDB) ZIncrBy ¶
ZIncrBy increments the score of member in the sorted set stored at key by increment. If member does not exist in the sorted set, it is added with increment as its score (as if its previous score was 0.0). If key does not exist, a new sorted set with the specified member as its sole member is created.
func (*LazyDB) ZPopMax ¶
ZPopMax Removes and returns up to count members with the highest scores in the sorted set stored at key. When left unspecified, the default value for count is 1. Specifying a count value that is higher than the sorted set's cardinality will not produce an error.
func (*LazyDB) ZPopMaxWithCount ¶
func (*LazyDB) ZPopMin ¶
ZPopMin Removes and returns up to count members with the lowest scores in the sorted set stored at key. When left unspecified, the default value for count is 1. Specifying a count value that is higher than the sorted set's cardinality will not produce an error.
func (*LazyDB) ZPopMinWithCount ¶
func (*LazyDB) ZRange ¶
ZRange returns the specified range of elements in the sorted set stored at <key>.
func (*LazyDB) ZRangeWithScores ¶
func (db *LazyDB) ZRangeWithScores(key []byte, start, stop int) (members [][]byte, scores []float64)
ZRangeWithScores returns the specified range of elements in the sorted set stored at key.
func (*LazyDB) ZRank ¶
ZRank returns the rank of member in the sorted set stored at key, with the scores ordered from low to high. The rank (or index) is 0-based, which means that the member with the lowest score has rank 0.
func (*LazyDB) ZRem ¶
ZRem removes the specified members from the sorted set stored at key. Non existing members are ignored. An error is returned when key exists and does not hold a sorted set.
func (*LazyDB) ZRevRange ¶
ZRevRange returns the specified range of elements in the sorted set stored at key. The elements are considered to be ordered from the highest to the lowest score. Descending lexicographical order is used for elements with equal score.
func (*LazyDB) ZRevRangeWithScores ¶
func (db *LazyDB) ZRevRangeWithScores(key []byte, start, stop int) (members [][]byte, scores []float64)
ZRevRangeWithScores returns the specified range of elements in the sorted set stored at key. The elements are considered to be ordered from the highest to the lowest score. Descending lexicographical order is used for elements with equal score.
type MutexLogFile ¶
type MutexLogFile struct {
// contains filtered or unexported fields
}