Source code for scarlet.cache
[docs]class Cache:
"""Cache to hold all complex proximal operators, transformation etc.
Convention to use is that the lookup `name` refers to the class or method
that pushes content onto the cache, the `key` can be chosen at will.
"""
_cache = {}
[docs] @staticmethod
def check(name, key):
try:
Cache._cache[name]
except KeyError:
Cache._cache[name] = {}
return Cache._cache[name][key]
[docs] @staticmethod
def set(name, key, content):
try:
Cache._cache[name]
except KeyError:
Cache._cache[name] = {}
Cache._cache[name][key] = content
@staticmethod
def __repr__(self):
repr(Cache._cache)