1
0

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