/django/core/cache/backends/dummy.py

https://code.google.com/p/mango-py/ · Python · 46 lines · 33 code · 12 blank · 1 comment · 0 complexity · e76797cc69af3c95f1eaec5e18eec86f MD5 · raw file

  1. "Dummy cache backend"
  2. from django.core.cache.backends.base import BaseCache
  3. class DummyCache(BaseCache):
  4. def __init__(self, host, *args, **kwargs):
  5. BaseCache.__init__(self, *args, **kwargs)
  6. def add(self, key, value, timeout=None, version=None):
  7. key = self.make_key(key, version=version)
  8. self.validate_key(key)
  9. return True
  10. def get(self, key, default=None, version=None):
  11. key = self.make_key(key, version=version)
  12. self.validate_key(key)
  13. return default
  14. def set(self, key, value, timeout=None, version=None):
  15. key = self.make_key(key, version=version)
  16. self.validate_key(key)
  17. def delete(self, key, version=None):
  18. key = self.make_key(key, version=version)
  19. self.validate_key(key)
  20. def get_many(self, keys, version=None):
  21. return {}
  22. def has_key(self, key, version=None):
  23. key = self.make_key(key, version=version)
  24. self.validate_key(key)
  25. return False
  26. def set_many(self, data, version=None):
  27. pass
  28. def delete_many(self, keys, version=None):
  29. pass
  30. def clear(self):
  31. pass
  32. # For backwards compatibility
  33. class CacheClass(DummyCache):
  34. pass