CacheInterface.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) 2015 Fabien Potencier
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * Interface implemented by cache classes.
  12. *
  13. * It is highly recommended to always store templates on the filesystem to
  14. * benefit from the PHP opcode cache. This interface is mostly useful if you
  15. * need to implement a custom strategy for storing templates on the filesystem.
  16. *
  17. * @author Andrew Tch <andrew@noop.lv>
  18. */
  19. interface Twig_CacheInterface
  20. {
  21. /**
  22. * Generates a cache key for the given template class name.
  23. *
  24. * @param string $name The template name
  25. * @param string $className The template class name
  26. *
  27. * @return string
  28. */
  29. public function generateKey($name, $className);
  30. /**
  31. * Writes the compiled template to cache.
  32. *
  33. * @param string $key The cache key
  34. * @param string $content The template representation as a PHP class
  35. */
  36. public function write($key, $content);
  37. /**
  38. * Loads a template from the cache.
  39. *
  40. * @param string $key The cache key
  41. */
  42. public function load($key);
  43. /**
  44. * Returns the modification timestamp of a key.
  45. *
  46. * @param string $key The cache key
  47. *
  48. * @return int
  49. */
  50. public function getTimestamp($key);
  51. }