CacheEngineInterface.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  11. * @link https://cakephp.org CakePHP(tm) Project
  12. * @since 3.7.0
  13. * @license https://opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Cache;
  16. /**
  17. * Interface for cache engines that defines methods
  18. * outside of the PSR16 interface that are used by `Cache`.
  19. *
  20. * Internally Cache uses this interface when calling engine
  21. * methods.
  22. *
  23. * @since 3.7.0
  24. */
  25. interface CacheEngineInterface
  26. {
  27. /**
  28. * Write data for key into a cache engine if it doesn't exist already.
  29. *
  30. * @param string $key Identifier for the data.
  31. * @param mixed $value Data to be cached - anything except a resource.
  32. * @return bool True if the data was successfully cached, false on failure.
  33. * Or if the key existed already.
  34. */
  35. public function add($key, $value);
  36. /**
  37. * Increment a number under the key and return incremented value
  38. *
  39. * @param string $key Identifier for the data
  40. * @param int $offset How much to add
  41. * @return bool|int New incremented value, false otherwise
  42. */
  43. public function increment($key, $offset = 1);
  44. /**
  45. * Decrement a number under the key and return decremented value
  46. *
  47. * @param string $key Identifier for the data
  48. * @param int $offset How much to subtract
  49. * @return bool|int New incremented value, false otherwise
  50. */
  51. public function decrement($key, $offset = 1);
  52. /**
  53. * Clear all values belonging to the named group.
  54. *
  55. * Each implementation needs to decide whether actually
  56. * delete the keys or just augment a group generation value
  57. * to achieve the same result.
  58. *
  59. * @param string $group name of the group to be cleared
  60. * @return bool
  61. */
  62. public function clearGroup($group);
  63. }