forked from mirror/ledisdb
don't export some error
This commit is contained in:
parent
f702354738
commit
51349ea12a
|
@ -28,6 +28,14 @@ const (
|
||||||
defaultScanCount int = 10
|
defaultScanCount int = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
errKeySize = errors.New("invalid key size")
|
||||||
|
errValueSize = errors.New("invalid value size")
|
||||||
|
errHashFieldSize = errors.New("invalid hash field size")
|
||||||
|
errZSetMemberSize = errors.New("invalid zset member size")
|
||||||
|
errExpireValue = errors.New("invalid expire value")
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
//we don't support too many databases
|
//we don't support too many databases
|
||||||
MaxDBNumber uint8 = 16
|
MaxDBNumber uint8 = 16
|
||||||
|
@ -46,12 +54,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrKeySize = errors.New("invalid key size")
|
ErrScoreMiss = errors.New("zset score miss")
|
||||||
ErrValueSize = errors.New("invalid value size")
|
|
||||||
ErrHashFieldSize = errors.New("invalid hash field size")
|
|
||||||
ErrZSetMemberSize = errors.New("invalid zset member size")
|
|
||||||
ErrExpireValue = errors.New("invalid expire value")
|
|
||||||
ErrScoreMiss = errors.New("zset score miss")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -130,3 +130,7 @@ func (l *Ledis) RepliateRelayLog(relayLog string, offset int64) (int64, error) {
|
||||||
log.Error("can not go here")
|
log.Error("can not go here")
|
||||||
return offset, nil
|
return offset, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *Ledis) WriteRelayLog(data []byte) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@ const (
|
||||||
|
|
||||||
func checkHashKFSize(key []byte, field []byte) error {
|
func checkHashKFSize(key []byte, field []byte) error {
|
||||||
if len(key) > MaxKeySize || len(key) == 0 {
|
if len(key) > MaxKeySize || len(key) == 0 {
|
||||||
return ErrKeySize
|
return errKeySize
|
||||||
} else if len(field) > MaxHashFieldSize || len(field) == 0 {
|
} else if len(field) > MaxHashFieldSize || len(field) == 0 {
|
||||||
return ErrHashFieldSize
|
return errHashFieldSize
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,14 +15,14 @@ var errKVKey = errors.New("invalid encode kv key")
|
||||||
|
|
||||||
func checkKeySize(key []byte) error {
|
func checkKeySize(key []byte) error {
|
||||||
if len(key) > MaxKeySize || len(key) == 0 {
|
if len(key) > MaxKeySize || len(key) == 0 {
|
||||||
return ErrKeySize
|
return errKeySize
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkValueSize(value []byte) error {
|
func checkValueSize(value []byte) error {
|
||||||
if len(value) > MaxValueSize {
|
if len(value) > MaxValueSize {
|
||||||
return ErrValueSize
|
return errValueSize
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -360,7 +360,7 @@ func (db *DB) Scan(key []byte, count int, inclusive bool) ([]KVPair, error) {
|
||||||
|
|
||||||
func (db *DB) Expire(key []byte, duration int64) (int64, error) {
|
func (db *DB) Expire(key []byte, duration int64) (int64, error) {
|
||||||
if duration <= 0 {
|
if duration <= 0 {
|
||||||
return 0, ErrExpireValue
|
return 0, errExpireValue
|
||||||
}
|
}
|
||||||
|
|
||||||
t := db.kvTx
|
t := db.kvTx
|
||||||
|
@ -381,7 +381,7 @@ func (db *DB) Expire(key []byte, duration int64) (int64, error) {
|
||||||
|
|
||||||
func (db *DB) ExpireAt(key []byte, when int64) (int64, error) {
|
func (db *DB) ExpireAt(key []byte, when int64) (int64, error) {
|
||||||
if when <= time.Now().Unix() {
|
if when <= time.Now().Unix() {
|
||||||
return 0, ErrExpireValue
|
return 0, errExpireValue
|
||||||
}
|
}
|
||||||
|
|
||||||
t := db.kvTx
|
t := db.kvTx
|
||||||
|
|
|
@ -34,9 +34,9 @@ const (
|
||||||
|
|
||||||
func checkZSetKMSize(key []byte, member []byte) error {
|
func checkZSetKMSize(key []byte, member []byte) error {
|
||||||
if len(key) > MaxKeySize || len(key) == 0 {
|
if len(key) > MaxKeySize || len(key) == 0 {
|
||||||
return ErrKeySize
|
return errKeySize
|
||||||
} else if len(member) > MaxZSetMemberSize || len(member) == 0 {
|
} else if len(member) > MaxZSetMemberSize || len(member) == 0 {
|
||||||
return ErrZSetMemberSize
|
return errZSetMemberSize
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -484,7 +484,7 @@ func (db *DB) zIterator(key []byte, min int64, max int64, offset int, limit int,
|
||||||
|
|
||||||
func (db *DB) zRemRange(key []byte, min int64, max int64, offset int, limit int) (int64, error) {
|
func (db *DB) zRemRange(key []byte, min int64, max int64, offset int, limit int) (int64, error) {
|
||||||
if len(key) > MaxKeySize {
|
if len(key) > MaxKeySize {
|
||||||
return 0, ErrKeySize
|
return 0, errKeySize
|
||||||
}
|
}
|
||||||
|
|
||||||
t := db.zsetTx
|
t := db.zsetTx
|
||||||
|
@ -537,7 +537,7 @@ func (db *DB) zReverse(s []interface{}, withScores bool) []interface{} {
|
||||||
|
|
||||||
func (db *DB) zRange(key []byte, min int64, max int64, withScores bool, offset int, limit int, reverse bool) ([]interface{}, error) {
|
func (db *DB) zRange(key []byte, min int64, max int64, withScores bool, offset int, limit int, reverse bool) ([]interface{}, error) {
|
||||||
if len(key) > MaxKeySize {
|
if len(key) > MaxKeySize {
|
||||||
return nil, ErrKeySize
|
return nil, errKeySize
|
||||||
}
|
}
|
||||||
|
|
||||||
if offset < 0 {
|
if offset < 0 {
|
||||||
|
|
Loading…
Reference in New Issue