feat: support memcache meta responses (#4366)

Fixes #4348 and #3071

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2024-12-25 09:46:50 +02:00 committed by GitHub
parent c88c707341
commit 966a1a46fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 107 additions and 29 deletions

View file

@ -6,6 +6,7 @@ from meta_memcache import (
CacheClient,
connection_pool_factory_builder,
)
from meta_memcache.protocol import RequestFlags, Miss, Value, Success
DEFAULT_ARGS = {"memcached_port": 11211, "proactor_threads": 4}
@ -16,6 +17,14 @@ def test_basic(df_server: DflyInstance):
servers=[
ServerAddress(host="localhost", port=DEFAULT_ARGS.get("memcached_port")),
],
connection_pool_factory_fn=connection_pool_factory_builder(),
connection_pool_factory_fn=connection_pool_factory_builder(recv_timeout=5),
)
# TODO: to add integration tests
assert pool.set("key1", "value1", 100)
assert pool.set("key1", "value2", 0)
assert pool.get("key1") == "value2"
request_flags = RequestFlags(return_value=False)
response = pool.meta_get(Key("key1"), flags=request_flags)
assert isinstance(response, Success)
assert pool.get("key2") is None

View file

@ -137,7 +137,7 @@ def test_version(memcached_client: MCClient):
Our real version is being returned in the stats command.
Also verified manually that php client parses correctly the version string that ends with "DF".
"""
assert b"1.5.0 DF" == memcached_client.version()
assert b"1.6.0 DF" == memcached_client.version()
stats = memcached_client.stats()
version = stats[b"version"].decode("utf-8")
assert version.startswith("v") or version == "dev"