forked from mirror/ledisdb
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")
|
||||
ErrHashFieldSize = errors.New("invalid hash field 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 errZScoreKey = errors.New("invalid zscore key")
|
||||
var errScoreOverflow = errors.New("zset score overflow")
|
||||
var errScoreMiss = errors.New("zset score miss")
|
||||
|
||||
const (
|
||||
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 {
|
||||
return InvalidScore, err
|
||||
} else if v == nil {
|
||||
return InvalidScore, errScoreMiss
|
||||
return InvalidScore, ErrScoreMiss
|
||||
} else {
|
||||
if score, err = Int64(v, nil); err != nil {
|
||||
return InvalidScore, err
|
||||
|
|
|
@ -67,9 +67,13 @@ func zscoreCommand(c *client) error {
|
|||
}
|
||||
|
||||
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 {
|
||||
c.writeInteger(s)
|
||||
c.writeBulk(ledis.StrPutInt64(s))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue