Skip to content

Commit 9747a14

Browse files
committed
Refactor & optimize utils
- Replaced `copy_level` parameter with more flexible `postprocess` callable (defaults to `postprocess_copy_mutables`). Now supports None (no copy), shallow copy, deep copy, or custom post-processing. - Removed deprecated `cachedmethod` decorator (use cached(..., cache=lambda self: self._cache) instead). - `CacheInfo` namedtuple no longer includes the `memory` field. - Default cache changed from `FIFOCache` to `LRUCache`. - Fixed incorrect `is_method` handling. - Improved per-key lock management: now uses a plain `dict` instead of `defaultdict`, and removes the lock when no waiters remain (better memory behavior under high contention). - Improved key makers (`make_key`, `make_hash_key`, `make_typed_key`)
1 parent f205e6b commit 9747a14

3 files changed

Lines changed: 661 additions & 1 deletion

File tree

cachebox/__init__.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,18 @@
99
from ._core import __version__ as __version__
1010
from ._core import _small_offset_feature as _small_offset_feature
1111

12-
# utils
12+
# Utils
1313
from .utils import Frozen as Frozen
14+
from .utils import cached as cached
15+
from .utils import is_cached as is_cached
16+
17+
# Key maker functions
18+
from .utils import make_hash_key as make_hash_key
19+
from .utils import make_key as make_key
20+
from .utils import make_typed_key as make_typed_key
21+
22+
# Postprocess functions
23+
from .utils import postprocess_copy as postprocess_copy
24+
from .utils import postprocess_copy_mutables as postprocess_copy_mutables
25+
from .utils import postprocess_deepcopy as postprocess_deepcopy
26+
from .utils import postprocess_deepcopy_mutables as postprocess_deepcopy_mutables

0 commit comments

Comments
 (0)