blob: 6e8c409be731971a746e1fc4cff58758dde8fba0 [file] [log] [blame]
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01001<?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 public function generateKey(string $name, string $className): string;
29
30 /**
31 * Writes the compiled template to cache.
32 *
33 * @param string $content The template representation as a PHP class
34 */
35 public function write(string $key, string $content): void;
36
37 /**
38 * Loads a template from the cache.
39 */
40 public function load(string $key): void;
41
42 /**
43 * Returns the modification timestamp of a key.
44 */
45 public function getTimestamp(string $key): int;
46}