2013-09-17 11:46:33 -04:00
|
|
|
<?php
|
2024-05-23 03:26:56 -04:00
|
|
|
|
2013-09-17 11:46:33 -04: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
|
2013-09-17 11:46:33 -04:00
|
|
|
*/
|
2013-11-03 07:38:25 -05:00
|
|
|
// use OCP namespace for all classes that are considered public.
|
2024-05-23 03:26:56 -04:00
|
|
|
// This means that they should be used by apps instead of the internal Nextcloud classes
|
2019-11-22 14:52:10 -05:00
|
|
|
|
2013-09-17 11:46:33 -04:00
|
|
|
namespace OCP;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This interface defines method for accessing the file based user cache.
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 6.0.0
|
2013-09-17 11:46:33 -04:00
|
|
|
*/
|
|
|
|
|
interface ICache {
|
2024-07-10 06:42:46 -04:00
|
|
|
/**
|
|
|
|
|
* @since 30.0.0
|
|
|
|
|
*/
|
|
|
|
|
public const DEFAULT_TTL = 24 * 60 * 60;
|
|
|
|
|
|
2013-09-17 11:46:33 -04:00
|
|
|
/**
|
|
|
|
|
* Get a value from the user cache
|
|
|
|
|
* @param string $key
|
|
|
|
|
* @return mixed
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 6.0.0
|
2013-09-17 11:46:33 -04:00
|
|
|
*/
|
|
|
|
|
public function get($key);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set a value in the user cache
|
|
|
|
|
* @param string $key
|
|
|
|
|
* @param mixed $value
|
|
|
|
|
* @param int $ttl Time To Live in seconds. Defaults to 60*60*24
|
|
|
|
|
* @return bool
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 6.0.0
|
2013-09-17 11:46:33 -04:00
|
|
|
*/
|
|
|
|
|
public function set($key, $value, $ttl = 0);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if a value is set in the user cache
|
|
|
|
|
* @param string $key
|
|
|
|
|
* @return bool
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 6.0.0
|
2016-04-19 06:07:54 -04:00
|
|
|
* @deprecated 9.1.0 Directly read from GET to prevent race conditions
|
2013-09-17 11:46:33 -04:00
|
|
|
*/
|
|
|
|
|
public function hasKey($key);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Remove an item from the user cache
|
|
|
|
|
* @param string $key
|
|
|
|
|
* @return bool
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 6.0.0
|
2013-09-17 11:46:33 -04:00
|
|
|
*/
|
|
|
|
|
public function remove($key);
|
|
|
|
|
|
|
|
|
|
/**
|
2013-10-16 18:07:29 -04:00
|
|
|
* Clear the user cache of all entries starting with a prefix
|
2013-09-18 16:22:51 -04:00
|
|
|
* @param string $prefix (optional)
|
2013-09-17 11:46:33 -04:00
|
|
|
* @return bool
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 6.0.0
|
2013-09-17 11:46:33 -04:00
|
|
|
*/
|
|
|
|
|
public function clear($prefix = '');
|
2022-01-19 17:30:34 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if the cache implementation is available
|
|
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
|
|
|
|
public static function isAvailable(): bool;
|
2013-09-17 11:46:33 -04:00
|
|
|
}
|