diff --git a/redis_cache/__init__.py b/redis_cache/__init__.py index 08c0585..959e207 100644 --- a/redis_cache/__init__.py +++ b/redis_cache/__init__.py @@ -4,7 +4,7 @@ from inspect import signature def compact_dump(value): - return dumps(value, separators=(',', ':')) + return dumps(value, separators=(',', ':'), sort_keys=True) def get_args(fn, args, kwargs): """ @@ -168,7 +168,7 @@ def __init__(self, redis_client, prefix="rc", serializer=compact_dump, deseriali def get_full_prefix(self): - return f'{{{self.prefix}:{self.namespace}}}' + return f'{self.prefix}:{self.namespace}' def get_key(self, args, kwargs): normalized_args = get_args(self.original_fn, args, kwargs) diff --git a/tests/test_redis_cache.py b/tests/test_redis_cache.py index 7f1a15b..305ebd9 100644 --- a/tests/test_redis_cache.py +++ b/tests/test_redis_cache.py @@ -233,7 +233,7 @@ def add_custom_key_serializer(arg1, arg2): encoded_args = b64encode("{'arg1': 2, 'arg2': 3}".encode('utf-8')).decode('utf-8') assert r1 == r2 - assert client.exists(f'{{rc:test_redis_cache.test_custom_key_serializer..add_custom_key_serializer}}:{encoded_args}') + assert client.exists(f'rc:test_redis_cache.test_custom_key_serializer..add_custom_key_serializer:{encoded_args}') def test_basic_mget(cache):