Skip to content

Commit

Permalink
Return default from hash client (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pankrat authored and jparise committed Feb 20, 2022
1 parent a5b3495 commit 4cdf69d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pymemcache/client/hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ def set(self, key, *args, **kwargs):
return self._run_cmd('set', key, False, *args, **kwargs)

def get(self, key, *args, **kwargs):
return self._run_cmd('get', key, None, *args, **kwargs)
default = kwargs.get('default', None)
return self._run_cmd('get', key, default, *args, **kwargs)

def incr(self, key, *args, **kwargs):
return self._run_cmd('incr', key, False, *args, **kwargs)
Expand Down
2 changes: 2 additions & 0 deletions pymemcache/test/test_client_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ def test_no_servers_left_with_commands_return_default_value(self):

result = client.get('foo')
assert result is None
result = client.get('foo', default='default')
assert result == 'default'
result = client.set('foo', 'bar')
assert result is False

Expand Down

0 comments on commit 4cdf69d

Please sign in to comment.