mirror of https://github.com/ledisdb/ledisdb.git
fix the type of return value from zscore command
This commit is contained in:
parent
4a5f105449
commit
dee78beef1
|
@ -37,4 +37,5 @@ var (
|
||||||
ErrKeySize = errors.New("invalid key size")
|
ErrKeySize = errors.New("invalid key size")
|
||||||
ErrHashFieldSize = errors.New("invalid hash field size")
|
ErrHashFieldSize = errors.New("invalid hash field size")
|
||||||
ErrZSetMemberSize = errors.New("invalid zset member size")
|
ErrZSetMemberSize = errors.New("invalid zset member size")
|
||||||
|
ErrScoreMiss = errors.New("zset score miss")
|
||||||
)
|
)
|
||||||
|
|
|
@ -22,7 +22,6 @@ var errZSizeKey = errors.New("invalid zsize key")
|
||||||
var errZSetKey = errors.New("invalid zset key")
|
var errZSetKey = errors.New("invalid zset key")
|
||||||
var errZScoreKey = errors.New("invalid zscore key")
|
var errZScoreKey = errors.New("invalid zscore key")
|
||||||
var errScoreOverflow = errors.New("zset score overflow")
|
var errScoreOverflow = errors.New("zset score overflow")
|
||||||
var errScoreMiss = errors.New("zset score miss")
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
zsetNScoreSep byte = '<'
|
zsetNScoreSep byte = '<'
|
||||||
|
@ -324,7 +323,7 @@ func (db *DB) ZScore(key []byte, member []byte) (int64, error) {
|
||||||
if v, err := db.db.Get(k); err != nil {
|
if v, err := db.db.Get(k); err != nil {
|
||||||
return InvalidScore, err
|
return InvalidScore, err
|
||||||
} else if v == nil {
|
} else if v == nil {
|
||||||
return InvalidScore, errScoreMiss
|
return InvalidScore, ErrScoreMiss
|
||||||
} else {
|
} else {
|
||||||
if score, err = Int64(v, nil); err != nil {
|
if score, err = Int64(v, nil); err != nil {
|
||||||
return InvalidScore, err
|
return InvalidScore, err
|
||||||
|
|
|
@ -67,9 +67,13 @@ func zscoreCommand(c *client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if s, err := c.db.ZScore(args[0], args[1]); err != nil {
|
if s, err := c.db.ZScore(args[0], args[1]); err != nil {
|
||||||
return err
|
if err == ledis.ErrScoreMiss {
|
||||||
|
c.writeBulk(nil)
|
||||||
|
} else {
|
||||||
|
return err
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
c.writeInteger(s)
|
c.writeBulk(ledis.StrPutInt64(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue