You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.2 KiB

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