Skip to content

Use the cache directly without a decorator #13

Open
@mikhail

Description

@mikhail

I've a need to get/set values from an LFU cache directly, rather than as a function decorator. The need is as such:

def slow_function(*args, **kwargs)
    cache = choose_cache_out_of_many(*args)
    found = cache.get(*args, **kwags)
    if found: return found

    result = slow_code()

    cache.set(result, *args, **kwargs)

This pattern of having multiple caches and only knowing which one to leverage inside the function that is to be cached means I cannot use a decorator.

How can I access memoization caches directly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions