/opt/cloudlinux/venv/lib/python3.11/site-packages/clwpos
NameSizeModeActions
bin/-0755rm
cli_versions/-0755rm
feature_suites/-0755rm
hooks/-0755rm
migrations/-0755rm
object_cache/-0755rm
optimization_features/-0755rm
php/-0755rm
user/-0755rm
__pycache__/-0755rm
billing.py63920644editdlrm
cl_wpos_exceptions.py40200644editdlrm
constants.py56950644editdlrm
create_user_uid_dirs.py7540644editdlrm
cron.py21890644editdlrm
daemon.py407290644editdlrm
daemon_base.py29120644editdlrm
daemon_config.py6210644editdlrm
daemon_redis_lib.py158640644editdlrm
daemon_subscription_handler.py327350644editdlrm
data_collector_utils.py96440644editdlrm
logsetup.py41420644editdlrm
papi.py101040644editdlrm
parse.py21540644editdlrm
redis_configuration_pid_file_cleaner.py10370755editdlrm
report_generator.py265970644editdlrm
scoped_cache.py13720644editdlrm
socket_utils.py69380644editdlrm
stats.py123040644editdlrm
utils.py779730644editdlrm
whmcs_utils.py115330644editdlrm
wpos_admin.py764140644editdlrm
wpos_hooks.py84660755editdlrm
wpos_req_scanner.py54900644editdlrm
wp_config.py36360644editdlrm
wp_utils.py188070644editdlrm
__init__.py9280644editdlrm
Edit: /opt/cloudlinux/venv/lib/python3.11/site-packages/clwpos/scoped_cache.py (1372B)
""" This is a simple wrapper around lru_cache which allows us to enable caching only within some scope defined by contextmanager It makes it easier to cache some functions e.g. only inside wpos-user get scope and still be able to get fresh data in wpos-user enable where cached commands might return different results because of outside """ from contextlib import contextmanager from functools import lru_cache _CACHED_FUNCTIONS = {} CACHING_ENABLED = False @contextmanager def enable_caching(): """ This context manager sets global marker which enables caching """ global CACHING_ENABLED if CACHING_ENABLED: raise RuntimeError('nested scopes are not supported') try: CACHING_ENABLED = True yield finally: _clear_cache() CACHING_ENABLED = False def _clear_cache(): """ Clear cache of all registered functions """ for func in _CACHED_FUNCTIONS.values(): func.cache_clear() def cached_in_scope(func): """ Primary code which decides should we return cached result or fresh """ def _wrapper(*args, **kwargs): if CACHING_ENABLED: return _CACHED_FUNCTIONS[func.__name__](*args, **kwargs) return func(*args, **kwargs) cached_func = lru_cache()(func) _CACHED_FUNCTIONS[func.__name__] = cached_func return _wrapper