summaryrefslogtreecommitdiff
path: root/lib/CacheInterface.php
blob: 091c5f029acd562593ebaa253843dbfc8eca639e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
 * This file is part of RSS-Bridge, a PHP project capable of generating RSS and
 * Atom feeds for websites that don't have one.
 *
 * For the full license information, please view the UNLICENSE file distributed
 * with this source code.
 *
 * @package	Core
 * @license	http://unlicense.org/ UNLICENSE
 * @link	https://github.com/rss-bridge/rss-bridge
 */

/**
 * The cache interface
 */
interface CacheInterface {
	/**
	 * Set scope of the current cache
	 *
	 * If $scope is an empty string, the cache is set to a global context.
	 *
	 * @param string $scope The scope the data is related to
	 */
	public function setScope($scope);

	/**
	 * Set key to assign the current data
	 *
	 * Since $key can be anything, the cache implementation must ensure to
	 * assign the related data reliably; most commonly by serializing and
	 * hashing the key in an appropriate way.
	 *
	 * @param array $key The key the data is related to
	 */
	public function setKey($key);

	/**
	 * Loads data from cache
	 *
	 * @return mixed The cached data or null
	 */
	public function loadData();

	/**
	 * Stores data to the cache
	 *
	 * @param mixed $data The data to store
	 * @return self The cache object
	 */
	public function saveData($data);

	/**
	 * Returns the timestamp for the curent cache data
	 *
	 * @return int Timestamp or null
	 */
	public function getTime();

	/**
	 * Removes any data that is older than the specified age from cache
	 *
	 * @param int $seconds The cache age in seconds
	 */
	public function purgeCache($seconds);
}