1 # -*- coding: utf-8 -*-
2 # This file is part of django-ssify, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See README.md for more information.
5 from __future__ import unicode_literals
6 from django.core.cache import InvalidCacheBackendError
10 DEFAULT_TIMEOUT = object()
14 from django.core.cache import caches
16 from django.core.cache import get_cache
18 get_cache = lambda alias: caches[alias]
23 return [get_cache(c) for c in conf.CACHE_ALIASES]
26 return [get_cache('ssify')]
27 except InvalidCacheBackendError:
28 return [get_cache('default')]
31 def cache_include(path, content, timeout=DEFAULT_TIMEOUT, version=None):
32 for cache in get_caches():
33 if timeout is DEFAULT_TIMEOUT:
34 cache.set(path, content, version=version)
36 cache.set(path, content, timeout=timeout, version=version)
39 def flush_ssi_includes(paths=None):
40 for cache in get_caches():
44 cache.delete_many(paths)