ICacheFactory.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. * Get a distributed memory cache instance
  35. *
  36. * All entries added trough the cache instance will be namespaced by $prefix to prevent collisions between apps
  37. *
  38. * @param string $prefix
  39. * @return ICache
  40. * @since 7.0.0
  41. * @deprecated 13.0.0 Use either createLocking, createDistributed or createLocal
  42. */
  43. public function create(string $prefix = ''): ICache;
  44. /**
  45. * Check if any memory cache backend is available
  46. *
  47. * @return bool
  48. * @since 7.0.0
  49. */
  50. public function isAvailable(): bool;
  51. /**
  52. * Check if a local memory cache backend is available
  53. *
  54. * @return bool
  55. * @since 14.0.0
  56. */
  57. public function isLocalCacheAvailable(): bool;
  58. /**
  59. * create a cache instance for storing locks
  60. *
  61. * @param string $prefix
  62. * @return IMemcache
  63. * @since 13.0.0
  64. */
  65. public function createLocking(string $prefix = ''): IMemcache;
  66. /**
  67. * create a distributed cache instance
  68. *
  69. * @param string $prefix
  70. * @return ICache
  71. * @since 13.0.0
  72. */
  73. public function createDistributed(string $prefix = ''): ICache;
  74. /**
  75. * create a local cache instance
  76. *
  77. * @param string $prefix
  78. * @return ICache
  79. * @since 13.0.0
  80. */
  81. public function createLocal(string $prefix = ''): ICache;
  82. }