菜谱项目

StoreInterface.php 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. * @param string $url A URL
  64. *
  65. * @return bool true if the URL exists and has been purged, false otherwise
  66. */
  67. public function purge($url);
  68. /**
  69. * Cleanups storage.
  70. */
  71. public function cleanup();
  72. }