Cache.php 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /*
  3. * $Id$
  4. *
  5. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  6. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16. *
  17. * This software consists of voluntary contributions made by many individuals
  18. * and is licensed under the LGPL. For more information, see
  19. * <http://www.doctrine-project.org>.
  20. */
  21. namespace Doctrine\Common\Cache;
  22. /**
  23. * Interface for cache drivers.
  24. *
  25. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  26. * @link www.doctrine-project.org
  27. * @since 2.0
  28. * @version $Revision: 3938 $
  29. * @author Benjamin Eberlei <kontakt@beberlei.de>
  30. * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
  31. * @author Jonathan Wage <jonwage@gmail.com>
  32. * @author Roman Borschel <roman@code-factory.org>
  33. */
  34. interface Cache
  35. {
  36. /**
  37. * Fetches an entry from the cache.
  38. *
  39. * @param string $id cache id The id of the cache entry to fetch.
  40. * @return string The cached data or FALSE, if no cache entry exists for the given id.
  41. */
  42. function fetch($id);
  43. /**
  44. * Test if an entry exists in the cache.
  45. *
  46. * @param string $id cache id The cache id of the entry to check for.
  47. * @return boolean TRUE if a cache entry exists for the given cache id, FALSE otherwise.
  48. */
  49. function contains($id);
  50. /**
  51. * Puts data into the cache.
  52. *
  53. * @param string $id The cache id.
  54. * @param string $data The cache entry/data.
  55. * @param int $lifeTime The lifetime. If != 0, sets a specific lifetime for this cache entry (0 => infinite lifeTime).
  56. * @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise.
  57. */
  58. function save($id, $data, $lifeTime = 0);
  59. /**
  60. * Deletes a cache entry.
  61. *
  62. * @param string $id cache id
  63. * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise.
  64. */
  65. function delete($id);
  66. }