cache_buster.rst 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ============
  2. Cache Buster
  3. ============
  4. Cache buster is small feature that allows certain cache-based systems find out when data they were dependant on has been changed, making their cache no longer valid.
  5. Using Cache Buster
  6. ==================
  7. Cache buster lives in :py:mod:`misago.core.cachebuster` and provides following API:
  8. is_valid
  9. --------
  10. .. function:: is_valid(cache, version)
  11. Checks if specific cache version is valid or raises ``ValueError`` if cache key is invalid.
  12. get_version
  13. -----------
  14. .. function:: get_version(cache)
  15. Returns current valid cache version as an integer number or raises ``ValueError`` if cache key is invalid.
  16. invalidate
  17. ----------
  18. .. function:: invalidate(cache)
  19. Makes specified cache invalid.
  20. invalidate_all
  21. --------------
  22. .. function:: invalidate_all()
  23. Makes all versioned caches invalid.
  24. Adding Custom Cache Buster
  25. ==========================
  26. You may add and remove your own cache names to cache buster by using following commands:
  27. .. note::
  28. Don't forget to call `invalidate_all` function after adding or removing cache name from buster to force it to rebuild its own cache.
  29. register
  30. --------
  31. .. function:: register(cache)
  32. Registers new cache in cache buster for tracking.
  33. unregister
  34. ----------
  35. .. function:: unregister(cache)
  36. Removes cache from cache buster and disables its tracking. This function will raise ``ValueError`` if cache you are trying to unregister is not registered.