Skip to content

Commit

Permalink
fix of pinterest#549 and test added
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhanush-arch committed Feb 11, 2024
1 parent 8cd0d87 commit 09323b6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pymemcache/client/hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,17 @@ def replace(self, key, *args, **kwargs):
def touch(self, key, *args, **kwargs):
return self._run_cmd("touch", key, False, *args, **kwargs)

def stats(self, *args, **kwargs):
result = list()
for key, client in self.clients.items():
result.append(
(
key,
self._safely_run_func(client, client.stats, False, *args, **kwargs),
)
)
return result

def flush_all(self, *args, **kwargs) -> None:
for client in self.clients.values():
self._safely_run_func(client, client.flush_all, False, *args, **kwargs)
Expand Down
13 changes: 13 additions & 0 deletions pymemcache/test/test_client_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,19 @@ def test_noreply_flush(self):
client = self.make_client()
client.flush_all(noreply=True)

def test_stats_many_server(self):
client = self.make_client(
*[
[b"STAT fake_stats 1\r\n", b"END\r\n"],
[b"STAT fake_stats 2\r\n", b"END\r\n"],
]
)
result = client.stats()
assert result == [
("127.0.0.1:11012", {b"fake_stats": 1}),
("127.0.0.1:11013", {b"fake_stats": 2}),
]

def test_set_many_unix(self):
values = {"key1": "value1", "key2": "value2", "key3": "value3"}

Expand Down

0 comments on commit 09323b6

Please sign in to comment.