def test_purge(self): c = cache.SimpleCache(threshold=2) c.set('a', 'a') c.set('b', 'b') c.set('c', 'c') c.set('d', 'd') # Cache purges old items *before* it sets new ones. assert len(c._cache) == 3
def test_purge(self): c = cache.SimpleCache(threshold=2) c.set("a", "a") c.set("b", "b") c.set("c", "c") c.set("d", "d") # Cache purges old items *before* it sets new ones. assert len(c._cache) == 3
def test_get_dict(self): c = cache.SimpleCache() c.set('a', 'a') c.set('b', 'b') d = c.get_dict('a', 'b') assert 'a' in d assert 'a' == d['a'] assert 'b' in d assert 'b' == d['b']
def test_purge(self): with pytest.warns(WerkzeugContribDeprecationWarning, match='cache is deprecated'): c = cache.SimpleCache(threshold=2) c.set('a', 'a') c.set('b', 'b') c.set('c', 'c') c.set('d', 'd') # Cache purges old items *before* it sets new ones. assert len(c._cache) == 3
def __init__(self, app): cache_type = app.config.get('CACHE_TYPE') if cache_type == 'memcached': host = app.config.get('MEMCACHE_HOST') self._cache = cache.MemcachedCache([host]) elif cache_type == 'local': self._cache = cache.SimpleCache() else: self._cache = cache.NullCache()
def test_set_many(self): c = cache.SimpleCache() c.set_many({0: 0, 1: 1, 2: 4}) assert c.get(2) == 4 c.set_many((i, i*i) for i in xrange(3)) assert c.get(2) == 4
def cache(self): if utils.is_appengine(): return werkzeug_cache.MemcachedCache(default_timeout=0) return werkzeug_cache.SimpleCache(default_timeout=0)
import locale import calendar from datetime import datetime, date from werkzeug.contrib import cache import logging LOG = logging.getLogger(__name__) locale.setlocale(locale.LC_ALL, 'es_PY.UTF-8') results = cache.SimpleCache() def get_trimester(cur_date=None): if cur_date is None: now = datetime.now() else: now = cur_date month = now.month trim = "" for m in range(month, month + 3): trim += calendar.month_abbr[(m % 12)].upper()[0] return trim def get_trimester_names(month=-1): if 0 < month < 13: month -= 1 else: month = datetime.now().month - 1