ICache.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. /**
  27. * Public interface of ownCloud for apps to use.
  28. * Cache interface
  29. *
  30. */
  31. // use OCP namespace for all classes that are considered public.
  32. // This means that they should be used by apps instead of the internal ownCloud classes
  33. namespace OCP;
  34. /**
  35. * This interface defines method for accessing the file based user cache.
  36. * @since 6.0.0
  37. */
  38. interface ICache {
  39. /**
  40. * Get a value from the user cache
  41. * @param string $key
  42. * @return mixed
  43. * @since 6.0.0
  44. */
  45. public function get($key);
  46. /**
  47. * Set a value in the user cache
  48. * @param string $key
  49. * @param mixed $value
  50. * @param int $ttl Time To Live in seconds. Defaults to 60*60*24
  51. * @return bool
  52. * @since 6.0.0
  53. */
  54. public function set($key, $value, $ttl = 0);
  55. /**
  56. * Check if a value is set in the user cache
  57. * @param string $key
  58. * @return bool
  59. * @since 6.0.0
  60. * @deprecated 9.1.0 Directly read from GET to prevent race conditions
  61. */
  62. public function hasKey($key);
  63. /**
  64. * Remove an item from the user cache
  65. * @param string $key
  66. * @return bool
  67. * @since 6.0.0
  68. */
  69. public function remove($key);
  70. /**
  71. * Clear the user cache of all entries starting with a prefix
  72. * @param string $prefix (optional)
  73. * @return bool
  74. * @since 6.0.0
  75. */
  76. public function clear($prefix = '');
  77. }