Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/cachier/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class Params:
cleanup_interval: timedelta = timedelta(days=1)
entry_size_limit: Optional[int] = None
allow_non_static_methods: bool = False
key_prefix: str = "cachier"
func_prefix: str = "."


_global_params = Params()
Expand Down
3 changes: 3 additions & 0 deletions src/cachier/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def cachier(
mongetter: Optional[Mongetter] = None,
sql_engine: Optional[Union[str, Any, Callable[[], Any]]] = None,
redis_client: Optional["RedisClient"] = None,
key_prefix: Optional[str] = None,
s3_bucket: Optional[str] = None,
s3_prefix: str = "cachier",
s3_client: Optional["S3Client"] = None,
Expand Down Expand Up @@ -357,6 +358,7 @@ def cachier(
backend = _update_with_defaults(backend, "backend")
mongetter = _update_with_defaults(mongetter, "mongetter")
size_limit_bytes = parse_bytes(_update_with_defaults(entry_size_limit, "entry_size_limit"))
key_prefix = _update_with_defaults(key_prefix, "key_prefix")

# Create metrics object if enabled
cache_metrics = None
Expand Down Expand Up @@ -407,6 +409,7 @@ def cachier(
wait_for_calc_timeout=wait_for_calc_timeout,
entry_size_limit=size_limit_bytes,
metrics=cache_metrics,
key_prefix=key_prefix,
)
elif backend == "s3":
core = _S3Core(
Expand Down
2 changes: 1 addition & 1 deletion src/cachier/cores/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _get_func_str(func: Callable) -> str:
__name__, but at runtime the decorated functions always do.

"""
return f".{func.__module__}.{func.__name__}"
return f"{_update_with_defaults('.', 'func_prefix')}{func.__module__}.{func.__name__}"
Comment on lines 38 to +40


class _BaseCore(metaclass=abc.ABCMeta):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_core_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def test_get_default_params():
"cleanup_interval",
"cleanup_stale",
"entry_size_limit",
"func_prefix",
"hash_func",
"key_prefix",
"mongetter",
"next_time",
"pickle_reload",
Expand Down
Loading