ICacheFactory.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. *
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. namespace OCP;
  25. /**
  26. * Interface ICacheFactory
  27. *
  28. * @package OCP
  29. * @since 7.0.0
  30. */
  31. interface ICacheFactory{
  32. /**
  33. * Get a distributed memory cache instance
  34. *
  35. * All entries added trough the cache instance will be namespaced by $prefix to prevent collisions between apps
  36. *
  37. * @param string $prefix
  38. * @return ICache
  39. * @since 7.0.0
  40. * @deprecated 13.0.0 Use either createLocking, createDistributed or createLocal
  41. */
  42. public function create(string $prefix = ''): ICache;
  43. /**
  44. * Check if any memory cache backend is available
  45. *
  46. * @return bool
  47. * @since 7.0.0
  48. */
  49. public function isAvailable(): bool;
  50. /**
  51. * Check if a local memory cache backend is available
  52. *
  53. * @return bool
  54. * @since 14.0.0
  55. */
  56. public function isLocalCacheAvailable(): bool;
  57. /**
  58. * create a cache instance for storing locks
  59. *
  60. * @param string $prefix
  61. * @return IMemcache
  62. * @since 13.0.0
  63. */
  64. public function createLocking(string $prefix = ''): IMemcache;
  65. /**
  66. * create a distributed cache instance
  67. *
  68. * @param string $prefix
  69. * @return ICache
  70. * @since 13.0.0
  71. */
  72. public function createDistributed(string $prefix = ''): ICache;
  73. /**
  74. * create a local cache instance
  75. *
  76. * @param string $prefix
  77. * @return ICache
  78. * @since 13.0.0
  79. */
  80. public function createLocal(string $prefix = ''): ICache;
  81. }