2014-05-16 11:04:35 +04:00
|
|
|
package ledis
|
|
|
|
|
2014-05-20 04:41:24 +04:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
)
|
|
|
|
|
2014-11-21 05:32:25 +03:00
|
|
|
const Version = "0.4"
|
|
|
|
|
2014-05-16 11:04:35 +04:00
|
|
|
const (
|
2014-07-11 09:27:40 +04:00
|
|
|
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
|
2014-08-11 10:52:43 +04:00
|
|
|
SetType byte = 11
|
|
|
|
SSizeType byte = 12
|
2014-07-09 13:01:29 +04:00
|
|
|
|
|
|
|
maxDataType byte = 100
|
|
|
|
|
2014-10-29 11:02:46 +03:00
|
|
|
/*
|
|
|
|
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
|
2014-09-17 19:06:42 +04:00
|
|
|
|
|
|
|
MetaType byte = 201
|
2014-07-11 09:27:40 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
TypeName = map[byte]string{
|
|
|
|
KVType: "kv",
|
|
|
|
HashType: "hash",
|
|
|
|
HSizeType: "hsize",
|
|
|
|
ListType: "list",
|
|
|
|
LMetaType: "lmeta",
|
|
|
|
ZSetType: "zset",
|
|
|
|
ZSizeType: "zsize",
|
|
|
|
ZScoreType: "zscore",
|
|
|
|
BitType: "bit",
|
|
|
|
BitMetaType: "bitmeta",
|
2014-08-11 10:52:43 +04:00
|
|
|
SetType: "set",
|
|
|
|
SSizeType: "ssize",
|
2014-07-11 09:27:40 +04:00
|
|
|
ExpTimeType: "exptime",
|
|
|
|
ExpMetaType: "expmeta",
|
|
|
|
}
|
2014-05-16 11:04:35 +04:00
|
|
|
)
|
2014-05-20 04:41:24 +04:00
|
|
|
|
2014-05-23 07:44:50 +04:00
|
|
|
const (
|
2014-05-23 08:39:56 +04:00
|
|
|
defaultScanCount int = 10
|
2014-05-23 07:44:50 +04:00
|
|
|
)
|
|
|
|
|
2014-06-05 11:46:38 +04:00
|
|
|
var (
|
|
|
|
errKeySize = errors.New("invalid key size")
|
|
|
|
errValueSize = errors.New("invalid value size")
|
|
|
|
errHashFieldSize = errors.New("invalid hash field size")
|
2014-08-11 10:52:43 +04:00
|
|
|
errSetMemberSize = errors.New("invalid set member size")
|
2014-06-05 11:46:38 +04:00
|
|
|
errZSetMemberSize = errors.New("invalid zset member size")
|
|
|
|
errExpireValue = errors.New("invalid expire value")
|
|
|
|
)
|
|
|
|
|
2014-05-20 04:41:24 +04:00
|
|
|
const (
|
|
|
|
//we don't support too many databases
|
|
|
|
MaxDBNumber uint8 = 16
|
|
|
|
|
|
|
|
//max key size
|
2014-05-28 10:20:34 +04:00
|
|
|
MaxKeySize int = 1024
|
2014-05-20 04:41:24 +04:00
|
|
|
|
|
|
|
//max hash field size
|
2014-05-28 10:20:34 +04:00
|
|
|
MaxHashFieldSize int = 1024
|
2014-05-20 04:41:24 +04:00
|
|
|
|
|
|
|
//max zset member size
|
2014-05-28 10:20:34 +04:00
|
|
|
MaxZSetMemberSize int = 1024
|
|
|
|
|
2014-08-11 10:52:43 +04:00
|
|
|
//max set member size
|
|
|
|
MaxSetMemberSize int = 1024
|
|
|
|
|
2014-05-28 10:20:34 +04:00
|
|
|
//max value size
|
2014-10-23 20:26:28 +04:00
|
|
|
MaxValueSize int = 1024 * 1024 * 1024
|
2014-05-20 04:41:24 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2014-09-23 13:28:09 +04:00
|
|
|
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")
|
2014-05-27 12:05:24 +04:00
|
|
|
)
|
2014-09-02 13:55:12 +04:00
|
|
|
|
|
|
|
const (
|
2014-09-25 06:44:07 +04:00
|
|
|
DBAutoCommit uint8 = 0x0
|
|
|
|
DBInTransaction uint8 = 0x1
|
|
|
|
DBInMulti uint8 = 0x2
|
2014-09-02 13:55:12 +04:00
|
|
|
)
|
2015-02-05 10:37:17 +03:00
|
|
|
|
|
|
|
const (
|
|
|
|
BitAND = "and"
|
|
|
|
BitOR = "or"
|
|
|
|
BitXOR = "xor"
|
|
|
|
BitNot = "not"
|
|
|
|
)
|