Skip to content

Commit b01b850

Browse files
committed
refactor(redis_func_cache): improve type hints and code organization
- Add Final type hint to constants module - Reorder fields in HashConfig dataclass - Improve docstring formatting and clarity - Maintain existing functionality and behavior
1 parent 6157e92 commit b01b850

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/redis_func_cache/constants.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"""Constants"""
22

3-
DEFAULT_MAXSIZE = 1024
3+
from typing import Final
4+
5+
DEFAULT_MAXSIZE: Final = 1024
46
"""Default maximum size of the cache."""
57

6-
DEFAULT_TTL = 3600
8+
DEFAULT_TTL: Final = 3600
79
"""Default time-to-live in seconds of the cache."""
810

9-
DEFAULT_PREFIX = "func-cache:"
11+
DEFAULT_PREFIX: Final = "func-cache:"
1012
"""Default prefix for the cache keys."""

src/redis_func_cache/mixins/hash.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@
4848
class HashConfig:
4949
"""A :func:`dataclasses.dataclass` Configurator for :class:`.AbstractHashMixin`"""
5050

51-
serializer: Callable[[Any], bytes]
52-
"""function to serialize function positional and keyword arguments."""
5351
algorithm: str
5452
"""name for hashing algorithm
5553
5654
The name must be supported by :mod:`hashlib`.
5755
"""
56+
serializer: Callable[[Any], bytes]
57+
"""function to serialize function positional and keyword arguments."""
5858
decoder: Optional[Callable[[Hash], KeyT]] = None
5959
"""function to decode hash digest to member of a sorted/unsorted set and also field name of a hash map in redis.
6060

0 commit comments

Comments
 (0)