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