temporalcache package

Submodules

temporalcache.expire.daily(on=0, tz=None, maxsize=128, persistent='', custom=None, **kwargs)[source]
temporalcache.expire.expire(second=None, minute=None, hour=None, day=None, day_of_week=None, week=None, month=None, tz=None, maxsize=128, persistent='', custom=None, **kwargs)[source]

Expires all entries in the cache @ whole number time

for example, @expire(0, 30, 16) will expire the cache at 4:30pm every day

temporalcache.expire.hourly(on=0, tz=None, maxsize=128, persistent='', custom=None, **kwargs)[source]
temporalcache.expire.minutely(on=0, tz=None, maxsize=128, persistent='', custom=None, **kwargs)[source]
temporalcache.expire.monthly(on=0, tz=None, maxsize=128, persistent='', custom=None, **kwargs)[source]
temporalcache.interval.daily(maxsize=128, persistent='', custom=None, **kwargs)[source]
temporalcache.interval.hourly(maxsize=128, persistent='', custom=None, **kwargs)[source]
temporalcache.interval.interval(seconds=0, minutes=0, hours=0, days=0, weeks=0, months=0, years=0, maxsize=128, persistent='', custom=None, **kwargs)[source]

Expires all entries in the cache every interval

temporalcache.interval.minutely(maxsize=128, persistent='', custom=None, **kwargs)[source]
temporalcache.interval.monthly(maxsize=128, persistent='', custom=None, **kwargs)[source]

The MIT License (MIT)

Copyright (c) 2013 abarnert

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

temporalcache.persistent_lru_cache.persistent_lru_cache(filename, save_every=1, maxsize=128, typed=False)[source]

Least-recently-used cache decorator.

filename is a path to a pickle file that will store the cache between runs.

If save_every is set to None, the cache will only be saved at exit (or when wrapper.cache_save is explicitly callde). If it’s a number N, the cache will be saved every N cache misses.

If maxsize is set to None, the LRU features are disabled and the cache can grow without bound.

If typed is True, arguments of different types will be cached separately. For example, f(3.0) and f(3) will be treated as distinct calls with distinct results.

Arguments to the cached function must be hashable.

View the cache statistics named tuple (hits, misses, maxsize, currsize) with f.cache_info(). Clear the cache and statistics with f.cache_clear(). Access the underlying function with f.__wrapped__.

See: http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used

class temporalcache.utils.StorageBase[source]

Bases: object

cache_clear()[source]
exception temporalcache.utils.TCException[source]

Bases: Exception

temporalcache.utils.calc[source]
temporalcache.utils.disable()[source]
temporalcache.utils.enable()[source]
temporalcache.utils.should_expire(last, now, secondly=None, minutely=None, hourly=None, daily=None, day_of_week=None, weekly=None, monthly=None)[source]

should the cache expire? last - datetime now - datetime

if yearly:
necessary_distance = calc(0, 0, 0, 0, 0, 0, yearly)