2014-01-08 09:18:12 -05:00
|
|
|
<?php
|
2019-12-03 13:57:53 -05:00
|
|
|
|
2018-01-16 14:44:51 -05:00
|
|
|
declare(strict_types=1);
|
2014-01-08 09:18:12 -05:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2014-01-08 09:18:12 -05:00
|
|
|
*/
|
|
|
|
|
namespace OCP;
|
|
|
|
|
|
2015-04-16 11:00:08 -04:00
|
|
|
/**
|
|
|
|
|
* Interface ICacheFactory
|
|
|
|
|
*
|
|
|
|
|
* @since 7.0.0
|
|
|
|
|
*/
|
2014-01-24 10:01:19 -05:00
|
|
|
interface ICacheFactory {
|
2014-01-09 07:54:50 -05:00
|
|
|
/**
|
2014-01-24 10:01:19 -05:00
|
|
|
* Check if any memory cache backend is available
|
2014-01-09 07:54:50 -05:00
|
|
|
*
|
|
|
|
|
* @return bool
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 7.0.0
|
2014-01-09 07:54:50 -05:00
|
|
|
*/
|
2018-01-16 14:44:51 -05:00
|
|
|
public function isAvailable(): bool;
|
2017-09-19 09:52:52 -04:00
|
|
|
|
2018-03-13 13:18:04 -04:00
|
|
|
/**
|
|
|
|
|
* Check if a local memory cache backend is available
|
|
|
|
|
*
|
|
|
|
|
* @return bool
|
|
|
|
|
* @since 14.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function isLocalCacheAvailable(): bool;
|
|
|
|
|
|
2017-09-19 09:52:52 -04:00
|
|
|
/**
|
|
|
|
|
* create a cache instance for storing locks
|
|
|
|
|
*
|
|
|
|
|
* @param string $prefix
|
2018-01-16 14:44:51 -05:00
|
|
|
* @return IMemcache
|
2017-09-19 09:52:52 -04:00
|
|
|
* @since 13.0.0
|
|
|
|
|
*/
|
2018-01-16 14:44:51 -05:00
|
|
|
public function createLocking(string $prefix = ''): IMemcache;
|
2017-09-19 09:52:52 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* create a distributed cache instance
|
|
|
|
|
*
|
|
|
|
|
* @param string $prefix
|
2018-01-16 14:44:51 -05:00
|
|
|
* @return ICache
|
2017-09-19 09:52:52 -04:00
|
|
|
* @since 13.0.0
|
|
|
|
|
*/
|
2018-01-16 14:44:51 -05:00
|
|
|
public function createDistributed(string $prefix = ''): ICache;
|
2017-09-19 09:52:52 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* create a local cache instance
|
|
|
|
|
*
|
|
|
|
|
* @param string $prefix
|
2018-01-16 14:44:51 -05:00
|
|
|
* @return ICache
|
2017-09-19 09:52:52 -04:00
|
|
|
* @since 13.0.0
|
|
|
|
|
*/
|
2018-01-16 14:44:51 -05:00
|
|
|
public function createLocal(string $prefix = ''): ICache;
|
2023-10-11 07:29:21 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create an in-memory cache instance
|
|
|
|
|
*
|
|
|
|
|
* Useful for remembering values inside one process. Cache memory is cleared
|
|
|
|
|
* when the object is garbage-collected. Implementation may also expire keys
|
|
|
|
|
* earlier when the TTL is reached or too much memory is consumed.
|
|
|
|
|
*
|
|
|
|
|
* Cache keys are local to the cache object. When building two in-memory
|
|
|
|
|
* caches, there is no data exchange between the instances.
|
|
|
|
|
*
|
|
|
|
|
* @param int $capacity maximum number of cache keys
|
|
|
|
|
* @return ICache
|
|
|
|
|
* @since 28.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function createInMemory(int $capacity = 512): ICache;
|
2014-01-08 09:18:12 -05:00
|
|
|
}
|