StoreInterface.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. * @param Request $request A Request instance
  27. *
  28. * @return Response|null A Response instance, or null if no cache entry was found
  29. */
  30. public function lookup(Request $request);
  31. /**
  32. * Writes a cache entry to the store for the given Request and Response.
  33. *
  34. * Existing entries are read and any that match the response are removed. This
  35. * method calls write with the new list of cache entries.
  36. *
  37. * @param Request $request A Request instance
  38. * @param Response $response A Response instance
  39. *
  40. * @return string The key under which the response is stored
  41. */
  42. public function write(Request $request, Response $response);
  43. /**
  44. * Invalidates all cache entries that match the request.
  45. *
  46. * @param Request $request A Request instance
  47. */
  48. public function invalidate(Request $request);
  49. /**
  50. * Locks the cache for a given Request.
  51. *
  52. * @param Request $request A Request instance
  53. *
  54. * @return Boolean|string true if the lock is acquired, the path to the current lock otherwise
  55. */
  56. public function lock(Request $request);
  57. /**
  58. * Releases the lock for the given Request.
  59. *
  60. * @param Request $request A Request instance
  61. *
  62. * @return Boolean False if the lock file does not exist or cannot be unlocked, true otherwise
  63. */
  64. public function unlock(Request $request);
  65. /**
  66. * Returns whether or not a lock exists.
  67. *
  68. * @param Request $request A Request instance
  69. *
  70. * @return Boolean true if lock exists, false otherwise
  71. */
  72. public function isLocked(Request $request);
  73. /**
  74. * Purges data for the given URL.
  75. *
  76. * @param string $url A URL
  77. *
  78. * @return Boolean true if the URL exists and has been purged, false otherwise
  79. */
  80. public function purge($url);
  81. /**
  82. * Cleanups storage.
  83. */
  84. public function cleanup();
  85. }