ICacheFactory.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Robin Appelman <robin@icewind.nl>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  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. namespace OCP;
  27. /**
  28. * Interface ICacheFactory
  29. *
  30. * @since 7.0.0
  31. */
  32. interface ICacheFactory {
  33. /**
  34. * Check if any memory cache backend is available
  35. *
  36. * @return bool
  37. * @since 7.0.0
  38. */
  39. public function isAvailable(): bool;
  40. /**
  41. * Check if a local memory cache backend is available
  42. *
  43. * @return bool
  44. * @since 14.0.0
  45. */
  46. public function isLocalCacheAvailable(): bool;
  47. /**
  48. * create a cache instance for storing locks
  49. *
  50. * @param string $prefix
  51. * @return IMemcache
  52. * @since 13.0.0
  53. */
  54. public function createLocking(string $prefix = ''): IMemcache;
  55. /**
  56. * create a distributed cache instance
  57. *
  58. * @param string $prefix
  59. * @return ICache
  60. * @since 13.0.0
  61. */
  62. public function createDistributed(string $prefix = ''): ICache;
  63. /**
  64. * create a local cache instance
  65. *
  66. * @param string $prefix
  67. * @return ICache
  68. * @since 13.0.0
  69. */
  70. public function createLocal(string $prefix = ''): ICache;
  71. /**
  72. * Create an in-memory cache instance
  73. *
  74. * Useful for remembering values inside one process. Cache memory is cleared
  75. * when the object is garbage-collected. Implementation may also expire keys
  76. * earlier when the TTL is reached or too much memory is consumed.
  77. *
  78. * Cache keys are local to the cache object. When building two in-memory
  79. * caches, there is no data exchange between the instances.
  80. *
  81. * @param int $capacity maximum number of cache keys
  82. * @return ICache
  83. * @since 28.0.0
  84. */
  85. public function createInMemory(int $capacity = 512): ICache;
  86. }