Documentation
¶
Index ¶
Constants ¶
View Source
const ( //DefaultAddr default kdb server address DefaultAddr = "127.0.0.1:5200" // DefaultDirPath kdb data dir DefaultDirPath = "/tmp/kdb_server" //DefaultBlockSize db file size : 16MB DefaultBlockSize = 16 * 1024 * 1024 // DefaultMaxKeySize 默认的key最大值 128字节 // default max key size: 128 bytes DefaultMaxKeySize = uint32(128) // DefaultMaxValueSize 默认的value最大值 1MB // default max value size: 1mb DefaultMaxValueSize = uint32(1 * 1024 * 1024) // DefaultReclaimThreshold 默认回收磁盘空间的阈值,当已封存文件个数到达 4 时,可进行回收 // default disk reclaim threshold: 4 DefaultReclaimThreshold = 4 )
View Source
const ( StringSet uint16 = iota StringRem )
string operations
View Source
const ( ListLPush uint16 = iota ListRPush ListLPop ListRPop ListLRem ListLInsert ListLSet ListLTrim )
list operations
View Source
const ( HashHSet uint16 = iota HashHDel )
hash table operations
View Source
const ( SetSAdd uint16 = iota SetSRem SetSMove )
set operations
View Source
const ( ZSetZAdd uint16 = iota ZSetZRem )
sorted set operations
View Source
const ( // ExtraSeparator 额外信息的分隔符,用于存储一些额外的信息(因此一些操作的value中不能包含此分隔符) // separator of the extra info ExtraSeparator = "\\0" )
Variables ¶
View Source
var ( // ErrEmptyKey the key is empty ErrEmptyKey = errors.New("kdb: the key is empty") // ErrKeyNotExist key not exist ErrKeyNotExist = errors.New("kdb: key not exist") // ErrKeyTooLarge the key too large ErrKeyTooLarge = errors.New("kdb: key exceeded the max length") // ErrValueTooLarge the value too large ErrValueTooLarge = errors.New("kdb: value exceeded the max length") // ErrNilIndexer the indexer is nil ErrNilIndexer = errors.New("kdb: indexer is nil") // ErrCfgNotExist the config is not exist ErrCfgNotExist = errors.New("kdb: the config file not exist") // ErrReclaimUnreached not ready to reclaim ErrReclaimUnreached = errors.New("kdb: unused space not reach the threshold") // ErrExtraContainsSeparator extra contains separator ErrExtraContainsSeparator = errors.New("kdb: extra contains separator \\0") // ErrInvalidTTL ttl is invalid ErrInvalidTTL = errors.New("kdb: invalid ttl") // ErrKeyExpired the key is expired ErrKeyExpired = errors.New("kdb: key is expired") )
Functions ¶
Types ¶
type ArchivedFiles ¶
ArchivedFiles define the archived files
type Config ¶
type Config struct { Addr string `json:"addr" toml:"addr"` //服务器地址 server address DirPath string `json:"dir_path" toml:"dir_path"` //数据库数据存储目录 kdb dir path of db file BlockSize int64 `json:"block_size" toml:"block_size"` //每个数据块文件的大小 each db file size RwMethod storage.FileRWMethod `json:"rw_method" toml:"rw_method"` //数据读写模式 db file read and write method IdxMode DataIndexMode `json:"idx_mode" toml:"idx_mode"` //数据索引模式 data index mode MaxKeySize uint32 `json:"max_key_size" toml:"max_key_size"` MaxValueSize uint32 `json:"max_value_size" toml:"max_value_size"` Sync bool `json:"sync" toml:"sync"` //每次写数据是否持久化 sync to disk ReclaimThreshold int `json:"reclaim_threshold" toml:"reclaim_threshold"` //回收磁盘空间的阈值 threshold to reclaim disk }
Config 数据库配置 the config options of kdb
type DataIndexMode ¶
type DataIndexMode int
DataIndexMode 数据索引模式
const ( // KeyValueRamMode 键和值均存在于内存中的模式 KeyValueRamMode DataIndexMode = iota // KeyOnlyRamMode 只有键存在于内存中的模式 KeyOnlyRamMode )
Source Files
¶
Click to show internal directories.
Click to hide internal directories.