ledisdb/ledis/const.go

151 lines
2.8 KiB
Go
Raw Permalink Normal View History

2014-05-16 11:04:35 +04:00
package ledis
2014-05-20 04:41:24 +04:00
import (
"errors"
)
2018-03-29 15:33:36 +03:00
// Version is for version
2015-04-09 16:36:30 +03:00
const Version = "0.5"
2014-11-21 05:32:25 +03:00
2018-03-29 15:33:36 +03:00
// DataType is defined for the different types
2015-03-02 06:10:54 +03:00
type DataType byte
// for out use
const (
KV DataType = iota
LIST
HASH
SET
ZSET
)
func (d DataType) String() string {
switch d {
case KV:
return KVName
case LIST:
return ListName
case HASH:
return HashName
case SET:
return SetName
case ZSET:
return ZSetName
default:
return "unknown"
}
}
2018-03-29 15:33:36 +03:00
// For different type name
2015-03-02 06:10:54 +03:00
const (
KVName = "KV"
ListName = "LIST"
HashName = "HASH"
SetName = "SET"
ZSetName = "ZSET"
)
// for backend store
2014-05-16 11:04:35 +04:00
const (
2015-03-03 04:21:00 +03: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
SetType byte = 11
SSizeType byte = 12
maxDataType byte = 100
/*
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
)
2018-03-29 15:33:36 +03:00
// TypeName is the map of type -> name
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",
SetType: "set",
SSizeType: "ssize",
ExpTimeType: "exptime",
ExpMetaType: "expmeta",
}
2014-05-20 04:41:24 +04:00
2014-05-23 07:44:50 +04:00
const (
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")
2015-12-10 07:09:10 +03:00
errListIndex = errors.New("invalid list index")
2014-06-05 11:46:38 +04:00
)
2018-03-29 15:33:36 +03:00
// For different const size configuration
2014-05-20 04:41:24 +04:00
const (
2018-03-29 15:33:36 +03:00
// max allowed databases
MaxDatabases int = 10240
2018-03-29 15:33:36 +03:00
// max key size
MaxKeySize int = 1024
2014-05-20 04:41:24 +04:00
2018-03-29 15:33:36 +03:00
// max hash field size
MaxHashFieldSize int = 1024
2014-05-20 04:41:24 +04:00
2018-03-29 15:33:36 +03:00
// max zset member size
MaxZSetMemberSize int = 1024
2018-03-29 15:33:36 +03:00
// max set member size
2014-08-11 10:52:43 +04:00
MaxSetMemberSize int = 1024
2018-03-29 15:33:36 +03:00
// max value size
MaxValueSize int = 1024 * 1024 * 1024
2014-05-20 04:41:24 +04:00
)
2018-03-29 15:33:36 +03:00
// For different common errors
2014-05-20 04:41:24 +04:00
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")
2014-05-27 12:05:24 +04:00
)
2014-09-02 13:55:12 +04:00
// const (
// DBAutoCommit uint8 = 0x0
// DBInTransaction uint8 = 0x1
// DBInMulti uint8 = 0x2
// )
2018-03-29 15:33:36 +03:00
// For bit operation
const (
BitAND = "and"
BitOR = "or"
BitXOR = "xor"
BitNot = "not"
)