IMemcache.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. * @param string $key
  30. * @param int $step
  31. * @return int | bool
  32. * @since 8.1.0
  33. */
  34. public function inc($key, $step = 1);
  35. /**
  36. * Decrease a stored number
  37. *
  38. * @param string $key
  39. * @param int $step
  40. * @return int | bool
  41. * @since 8.1.0
  42. */
  43. public function dec($key, $step = 1);
  44. /**
  45. * Compare and set
  46. *
  47. * @param string $key
  48. * @param mixed $old
  49. * @param mixed $new
  50. * @return bool
  51. * @since 8.1.0
  52. */
  53. public function cas($key, $old, $new);
  54. /**
  55. * Compare and delete
  56. *
  57. * @param string $key
  58. * @param mixed $old
  59. * @return bool
  60. * @since 8.1.0
  61. */
  62. public function cad($key, $old);
  63. }