summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug <douglaslong11@gmail.com>2020-03-18 14:34:19 -0600
committerGitHub <noreply@github.com>2020-03-18 13:34:19 -0700
commit51c76dae2c3c96ecaac0f2abd522fd344b0b2482 (patch)
tree861a20363e34292473099e47a988df96a5a938f8
parent86fc415d8383c7dbf7bd3442ab9d7d3e36a874d3 (diff)
downloadpymemcache-51c76dae2c3c96ecaac0f2abd522fd344b0b2482.tar.gz
HashClient pass encoding servers (#271)
pass the encoding from the hashed client to the pooled client when use_pooling is True.
-rw-r--r--pymemcache/client/hash.py1
-rw-r--r--pymemcache/test/test_client_hash.py27
2 files changed, 28 insertions, 0 deletions
diff --git a/pymemcache/client/hash.py b/pymemcache/client/hash.py
index 531d4c2..d8271ae 100644
--- a/pymemcache/client/hash.py
+++ b/pymemcache/client/hash.py
@@ -87,6 +87,7 @@ class HashClient(object):
'deserializer': deserializer,
'allow_unicode_keys': allow_unicode_keys,
'default_noreply': default_noreply,
+ 'encoding': encoding
}
if use_pooling is True:
diff --git a/pymemcache/test/test_client_hash.py b/pymemcache/test/test_client_hash.py
index 12e045d..311e382 100644
--- a/pymemcache/test/test_client_hash.py
+++ b/pymemcache/test/test_client_hash.py
@@ -268,4 +268,31 @@ class TestHashClient(ClientTestMixin, unittest.TestCase):
result = client.set_many(values, noreply=True)
assert result == []
+ def test_server_encoding_pooled(self):
+ """
+ test passed encoding from hash client to pooled clients
+ """
+ encoding = 'utf8'
+ from pymemcache.client.hash import HashClient
+ hash_client = HashClient(
+ [('example.com', 11211)], use_pooling=True,
+ encoding=encoding
+ )
+
+ for client in hash_client.clients.values():
+ assert client.encoding == encoding
+
+ def test_server_encoding_client(self):
+ """
+ test passed encoding from hash client to clients
+ """
+ encoding = 'utf8'
+ from pymemcache.client.hash import HashClient
+ hash_client = HashClient(
+ [('example.com', 11211)], encoding=encoding
+ )
+
+ for client in hash_client.clients.values():
+ assert client.encoding == encoding
+
# TODO: Test failover logic