| 148 |
lars |
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 |
|
|
|
15 |
namespace Symfony\Component\HttpKernel\HttpCache;
|
|
|
16 |
|
|
|
17 |
use Symfony\Component\HttpFoundation\Request;
|
|
|
18 |
use Symfony\Component\HttpFoundation\Response;
|
|
|
19 |
|
|
|
20 |
/**
|
|
|
21 |
* Interface implemented by HTTP cache stores.
|
|
|
22 |
*
|
|
|
23 |
* @author Fabien Potencier <fabien@symfony.com>
|
|
|
24 |
*/
|
|
|
25 |
interface StoreInterface
|
|
|
26 |
{
|
|
|
27 |
/**
|
|
|
28 |
* Locates a cached Response for the Request provided.
|
|
|
29 |
*/
|
|
|
30 |
public function lookup(Request $request): ?Response;
|
|
|
31 |
|
|
|
32 |
/**
|
|
|
33 |
* Writes a cache entry to the store for the given Request and Response.
|
|
|
34 |
*
|
|
|
35 |
* Existing entries are read and any that match the response are removed. This
|
|
|
36 |
* method calls write with the new list of cache entries.
|
|
|
37 |
*
|
|
|
38 |
* @return string The key under which the response is stored
|
|
|
39 |
*/
|
|
|
40 |
public function write(Request $request, Response $response): string;
|
|
|
41 |
|
|
|
42 |
/**
|
|
|
43 |
* Invalidates all cache entries that match the request.
|
|
|
44 |
*/
|
|
|
45 |
public function invalidate(Request $request);
|
|
|
46 |
|
|
|
47 |
/**
|
|
|
48 |
* Locks the cache for a given Request.
|
|
|
49 |
*
|
|
|
50 |
* @return bool|string true if the lock is acquired, the path to the current lock otherwise
|
|
|
51 |
*/
|
|
|
52 |
public function lock(Request $request): bool|string;
|
|
|
53 |
|
|
|
54 |
/**
|
|
|
55 |
* Releases the lock for the given Request.
|
|
|
56 |
*
|
|
|
57 |
* @return bool False if the lock file does not exist or cannot be unlocked, true otherwise
|
|
|
58 |
*/
|
|
|
59 |
public function unlock(Request $request): bool;
|
|
|
60 |
|
|
|
61 |
/**
|
|
|
62 |
* Returns whether or not a lock exists.
|
|
|
63 |
*
|
|
|
64 |
* @return bool true if lock exists, false otherwise
|
|
|
65 |
*/
|
|
|
66 |
public function isLocked(Request $request): bool;
|
|
|
67 |
|
|
|
68 |
/**
|
|
|
69 |
* Purges data for the given URL.
|
|
|
70 |
*
|
|
|
71 |
* @return bool true if the URL exists and has been purged, false otherwise
|
|
|
72 |
*/
|
|
|
73 |
public function purge(string $url): bool;
|
|
|
74 |
|
|
|
75 |
/**
|
|
|
76 |
* Cleanups storage.
|
|
|
77 |
*/
|
|
|
78 |
public function cleanup();
|
|
|
79 |
}
|