Skip to content

Commit

Permalink
New command: GETSET
Browse files Browse the repository at this point in the history
  • Loading branch information
kmerenkov committed May 18, 2010
1 parent 0b430cd commit a5ae34e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions brukva/client.py
Expand Up @@ -270,6 +270,9 @@ def get(self, key, callbacks=None):
def mget(self, keys, callbacks=None):
self.execute_command('MGET', callbacks, *keys)

def getset(self, key, value, callbacks=None):
self.execute_command('GETSET', callbacks, key, value)

def exists(self, key, callbacks=None):
self.execute_command('EXISTS', callbacks, key)

Expand Down
6 changes: 6 additions & 0 deletions tests/server_commands.py
Expand Up @@ -111,6 +111,12 @@ def test_mset_mget(self):
self.client.mget(['a', 'b'], [self.expect(['1', '2']), self.finish])
self.start()

def test_getset(self):
self.client.set('a', 1, self.expect(True))
self.client.getset('a', 2, self.expect('1'))
self.client.get('a', [self.expect('2'), self.finish])
self.start()

def test_hash(self):
self.client.hmset('foo', {'a': 1, 'b': 2}, self.expect(True))
self.client.hgetall('foo', self.expect({'a': '1', 'b': '2'}))
Expand Down

0 comments on commit a5ae34e

Please sign in to comment.