Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cache.py 646B

1234567891011121314151617181920212223242526
  1. from django.template.defaultfilters import slugify
  2. from .settings import get_cache_backend
  3. # Stripped down version of caching functions from django-dbtemplates
  4. # https://github.com/jezdez/django-dbtemplates/blob/develop/dbtemplates/utils/cache.py
  5. cache_backend = get_cache_backend()
  6. def get_cache_key(name):
  7. """
  8. Prefixes and slugify the key name
  9. """
  10. return 'post_office:template:%s' % (slugify(name))
  11. def set(name, content):
  12. return cache_backend.set(get_cache_key(name), content)
  13. def get(name):
  14. return cache_backend.get(get_cache_key(name))
  15. def delete(name):
  16. return cache_backend.delete(get_cache_key(name))