How to use the memoization.caching.plain_cache.get_caching_wrapper function in memoization

To help you get started, we’ve selected a few memoization examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lonelyenvoy / python-memoization / memoization / memoization.py View on Github external
def _create_cached_wrapper(user_function, max_size, ttl, algorithm, thread_safe, order_independent, custom_key_maker):
    """
    Factory that creates an actual executed function when a function is decorated with @cached
    """
    if max_size == 0:
        return statistic_cache.get_caching_wrapper(user_function, max_size, ttl, algorithm,
                                                   thread_safe, order_independent, custom_key_maker)
    elif max_size is None:
        return plain_cache.get_caching_wrapper(user_function, max_size, ttl, algorithm,
                                               thread_safe, order_independent, custom_key_maker)
    else:
        cache_toolkit = get_cache_toolkit(algorithm)
        return cache_toolkit.get_caching_wrapper(user_function, max_size, ttl, algorithm,
                                                 thread_safe, order_independent, custom_key_maker)