U afz@sDddlmZmZddlmZmZdZddZefeedddZd S) ) lru_cachewraps)datetime timedeltacs$i_tfdd}|S)zMA general-use memoizer decorator for class, object, function; supports kwargscs.t|t|}|kr&|||<|S)zActual implementation)str)argskwargskeycacheobjF/opt/nydus/tmp/pip-target-53d1vnqk/lib/python/primordial/cacheutils.pymemoizer szmemoize..memoizer)r r)r rrr rmemoize s r)secondsmaxsizecsfdd}|S)a1A decorator that wraps lru_cache and allows the setting of a lifetime in seconds, after which the cache will expire :param seconds: The number of seconds after which the cache will expire :param maxsize: The maximum number of entries in the cache before it will start dropping old entries csBtdtd_tj_tfdd}|S)N)r)rcs0tjkr&tj_||S)N)rutcnow expiration cache_clearlifetime)rr funcrr wrapped_func#sz.wrapper_cache..wrapped_func)rrrrrrr)rrrrrr wrapper_caches  z&timed_lru_cache..wrapper_cacher)rrrrrrtimed_lru_cachesrN) functoolsrrrrZDEFAULT_MAXSIZErintrrrrrs