return value on memcache client decr call
Closes-Bug: 1238204 Change-Id: I7d2ece118159637e5c5bf4bf5dd4ce4d2f6e4523
This commit is contained in:
parent
5964082b2c
commit
d4c6587505
@ -319,6 +319,7 @@ class MemcacheRing(object):
|
||||
interface consistent with set and set_multi methods
|
||||
:param timeout: ttl in memcache, deprecated, will be removed in future
|
||||
OpenStack releases
|
||||
:returns: result of incrementing
|
||||
:raises MemcacheConnectionError:
|
||||
"""
|
||||
if timeout:
|
||||
@ -370,12 +371,13 @@ class MemcacheRing(object):
|
||||
interface consistent with set and set_multi methods
|
||||
:param timeout: ttl in memcache, deprecated, will be removed in future
|
||||
OpenStack releases
|
||||
:returns: result of decrementing
|
||||
:raises MemcacheConnectionError:
|
||||
"""
|
||||
if timeout:
|
||||
logging.warn("parameter timeout has been deprecated, use time")
|
||||
|
||||
self.incr(key, delta=-delta, time=(time or timeout))
|
||||
return self.incr(key, delta=-delta, time=(time or timeout))
|
||||
|
||||
def delete(self, key):
|
||||
"""
|
||||
|
@ -217,15 +217,15 @@ class TestMemcached(unittest.TestCase):
|
||||
mock = MockMemcached()
|
||||
memcache_client._client_cache['1.2.3.4:11211'] = MockedMemcachePool(
|
||||
[(mock, mock)] * 2)
|
||||
memcache_client.incr('some_key', delta=5)
|
||||
self.assertEquals(memcache_client.incr('some_key', delta=5), 5)
|
||||
self.assertEquals(memcache_client.get('some_key'), '5')
|
||||
memcache_client.incr('some_key', delta=5)
|
||||
self.assertEquals(memcache_client.incr('some_key', delta=5), 10)
|
||||
self.assertEquals(memcache_client.get('some_key'), '10')
|
||||
memcache_client.incr('some_key', delta=1)
|
||||
self.assertEquals(memcache_client.incr('some_key', delta=1), 11)
|
||||
self.assertEquals(memcache_client.get('some_key'), '11')
|
||||
memcache_client.incr('some_key', delta=-5)
|
||||
self.assertEquals(memcache_client.incr('some_key', delta=-5), 6)
|
||||
self.assertEquals(memcache_client.get('some_key'), '6')
|
||||
memcache_client.incr('some_key', delta=-15)
|
||||
self.assertEquals(memcache_client.incr('some_key', delta=-15), 0)
|
||||
self.assertEquals(memcache_client.get('some_key'), '0')
|
||||
mock.read_return_none = True
|
||||
self.assertRaises(memcached.MemcacheConnectionError,
|
||||
@ -261,13 +261,13 @@ class TestMemcached(unittest.TestCase):
|
||||
mock = MockMemcached()
|
||||
memcache_client._client_cache['1.2.3.4:11211'] = MockedMemcachePool(
|
||||
[(mock, mock)] * 2)
|
||||
memcache_client.decr('some_key', delta=5)
|
||||
self.assertEquals(memcache_client.decr('some_key', delta=5), 0)
|
||||
self.assertEquals(memcache_client.get('some_key'), '0')
|
||||
memcache_client.incr('some_key', delta=15)
|
||||
self.assertEquals(memcache_client.incr('some_key', delta=15), 15)
|
||||
self.assertEquals(memcache_client.get('some_key'), '15')
|
||||
memcache_client.decr('some_key', delta=4)
|
||||
self.assertEquals(memcache_client.decr('some_key', delta=4), 11)
|
||||
self.assertEquals(memcache_client.get('some_key'), '11')
|
||||
memcache_client.decr('some_key', delta=15)
|
||||
self.assertEquals(memcache_client.decr('some_key', delta=15), 0)
|
||||
self.assertEquals(memcache_client.get('some_key'), '0')
|
||||
mock.read_return_none = True
|
||||
self.assertRaises(memcached.MemcacheConnectionError,
|
||||
|
Loading…
Reference in New Issue
Block a user