ssdb-py icon indicating copy to clipboard operation
ssdb-py copied to clipboard

一个zset 返回错误

Open ego008 opened this issue 10 years ago • 1 comments

对相同的name key 设置返回False,但实际已经设置成功

>>> db.zincr('test', 'a', 1)
3
>>> db.zincr('test', 'a', 1)
4
>>> db.zset('test', 'a', 6)
False
>>> db.zdel('test', 'a')
True
>>> db.zset('test', 'a', 6)
True
>>> db.zset('test', 'a', 9)
False
>>> db.zincr('test', 'a', 1)
10
>>> db.zset('test', 'a', 99)
False
>>> db.zget('test', 'a')
99
>>> 

ego008 avatar Mar 04 '14 14:03 ego008

这是正确行为

#### ZSET OPERATION ####
def zset(self, name, key, score=1):
    """
    Set the score of ``key`` from the zset ``name`` to ``score``

    Like **Redis.ZADD**

    :param string name: the zset name
    :param string key: the key name
    :param int score: the score for ranking
    :return: ``True`` if ``zset`` created a new score, otherwise ``False``
    :rtype: bool

    >>> ssdb.zset("zset_1", 'z', 1024)
    True
    >>> ssdb.zset("zset_1", 'a', 1024)
    False
    >>> ssdb.zset("zset_2", 'key_10', -4)
    >>>
    >>> ssdb.zget("zset_2", 'key1')
    42        
    """
    score = get_integer('score', score)        
    return self.execute_command('zset', name, key, score)
zadd = zset

pingany avatar Mar 28 '16 11:03 pingany