1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * This code is partially based on the Rack-Cache library by Ryan Tomayko,
9 * which is released under the MIT license.
10 *
11 * For the full copyright and license information, please view the LICENSE
12 * file that was distributed with this source code.
13 */
14
15namespace Symfony\Component\HttpKernel\HttpCache;
16
17use Symfony\Component\HttpFoundation\Request;
18use Symfony\Component\HttpFoundation\Response;
19
20/**
21 * Interface implemented by HTTP cache stores.
22 *
23 * @author Fabien Potencier <fabien@symfony.com>
24 */
25interface StoreInterface
26{
27    /**
28     * Locates a cached Response for the Request provided.
29     *
30     * @return Response|null A Response instance, or null if no cache entry was found
31     */
32    public function lookup(Request $request);
33
34    /**
35     * Writes a cache entry to the store for the given Request and Response.
36     *
37     * Existing entries are read and any that match the response are removed. This
38     * method calls write with the new list of cache entries.
39     *
40     * @return string The key under which the response is stored
41     */
42    public function write(Request $request, Response $response);
43
44    /**
45     * Invalidates all cache entries that match the request.
46     */
47    public function invalidate(Request $request);
48
49    /**
50     * Locks the cache for a given Request.
51     *
52     * @return bool|string true if the lock is acquired, the path to the current lock otherwise
53     */
54    public function lock(Request $request);
55
56    /**
57     * Releases the lock for the given Request.
58     *
59     * @return bool False if the lock file does not exist or cannot be unlocked, true otherwise
60     */
61    public function unlock(Request $request);
62
63    /**
64     * Returns whether or not a lock exists.
65     *
66     * @return bool true if lock exists, false otherwise
67     */
68    public function isLocked(Request $request);
69
70    /**
71     * Purges data for the given URL.
72     *
73     * @param string $url A URL
74     *
75     * @return bool true if the URL exists and has been purged, false otherwise
76     */
77    public function purge($url);
78
79    /**
80     * Cleanups storage.
81     */
82    public function cleanup();
83}
84