IMemcache.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. // use OCP namespace for all classes that are considered public.
  8. // This means that they should be used by apps instead of the internal Nextcloud classes
  9. namespace OCP;
  10. /**
  11. * This interface defines method for accessing the file based user cache.
  12. *
  13. * @since 8.1.0
  14. */
  15. interface IMemcache extends ICache {
  16. /**
  17. * Set a value in the cache if it's not already stored
  18. *
  19. * @param string $key
  20. * @param mixed $value
  21. * @param int $ttl Time To Live in seconds. Defaults to 60*60*24
  22. * @return bool
  23. * @since 8.1.0
  24. */
  25. public function add($key, $value, $ttl = 0);
  26. /**
  27. * Increase a stored number
  28. *
  29. * If no value is stored with the key, it will behave as if a 0 was stored.
  30. * If a non-numeric value is stored, the operation will fail and `false` is returned.
  31. *
  32. * @param string $key
  33. * @param int $step
  34. * @return int | bool
  35. * @since 8.1.0
  36. */
  37. public function inc($key, $step = 1);
  38. /**
  39. * Decrease a stored number
  40. *
  41. * If no value is stored with the key, the operation will fail and `false` is returned.
  42. * If a non-numeric value is stored, the operation will fail and `false` is returned.
  43. *
  44. * @param string $key
  45. * @param int $step
  46. * @return int | bool
  47. * @since 8.1.0
  48. */
  49. public function dec($key, $step = 1);
  50. /**
  51. * Compare and set
  52. *
  53. * @param string $key
  54. * @param mixed $old
  55. * @param mixed $new
  56. * @return bool
  57. * @since 8.1.0
  58. */
  59. public function cas($key, $old, $new);
  60. /**
  61. * Compare and delete
  62. *
  63. * @param string $key
  64. * @param mixed $old
  65. * @return bool
  66. * @since 8.1.0
  67. */
  68. public function cad($key, $old);
  69. }