ICache.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Lukas Reschke <lukas@statuscode.ch>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Thomas Müller <thomas.mueller@tmit.eu>
  8. * @author Thomas Tanghus <thomas@tanghus.net>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. /**
  26. * Public interface of ownCloud for apps to use.
  27. * Cache interface
  28. *
  29. */
  30. // use OCP namespace for all classes that are considered public.
  31. // This means that they should be used by apps instead of the internal ownCloud classes
  32. namespace OCP;
  33. /**
  34. * This interface defines method for accessing the file based user cache.
  35. * @since 6.0.0
  36. */
  37. interface ICache {
  38. /**
  39. * Get a value from the user cache
  40. * @param string $key
  41. * @return mixed
  42. * @since 6.0.0
  43. */
  44. public function get($key);
  45. /**
  46. * Set a value in the user cache
  47. * @param string $key
  48. * @param mixed $value
  49. * @param int $ttl Time To Live in seconds. Defaults to 60*60*24
  50. * @return bool
  51. * @since 6.0.0
  52. */
  53. public function set($key, $value, $ttl = 0);
  54. /**
  55. * Check if a value is set in the user cache
  56. * @param string $key
  57. * @return bool
  58. * @since 6.0.0
  59. * @deprecated 9.1.0 Directly read from GET to prevent race conditions
  60. */
  61. public function hasKey($key);
  62. /**
  63. * Remove an item from the user cache
  64. * @param string $key
  65. * @return bool
  66. * @since 6.0.0
  67. */
  68. public function remove($key);
  69. /**
  70. * Clear the user cache of all entries starting with a prefix
  71. * @param string $prefix (optional)
  72. * @return bool
  73. * @since 6.0.0
  74. */
  75. public function clear($prefix = '');
  76. }