]> git.mxchange.org Git - friendica.git/blob - src/Core/Cache/ICache.php
Merge pull request #1 from friendica/develop
[friendica.git] / src / Core / Cache / ICache.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2020, Friendica
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Core\Cache;
23
24 /**
25  * Cache Interface
26  */
27 interface ICache
28 {
29         /**
30          * Lists all cache keys
31          *
32          * @param string prefix optional a prefix to search
33          *
34          * @return array Empty if it isn't supported by the cache driver
35          */
36         public function getAllKeys($prefix = null);
37
38         /**
39          * Fetches cached data according to the key
40          *
41          * @param string $key The key to the cached data
42          *
43          * @return mixed Cached $value or "null" if not found
44          */
45         public function get($key);
46
47         /**
48          * Stores data in the cache identified by the key. The input $value can have multiple formats.
49          *
50          * @param string  $key      The cache key
51          * @param mixed   $value    The value to store
52          * @param integer $ttl      The cache lifespan, must be one of the Cache constants
53          *
54          * @return bool
55          */
56         public function set($key, $value, $ttl = Duration::FIVE_MINUTES);
57
58         /**
59          * Delete a key from the cache
60          *
61          * @param string $key      The cache key
62          *
63          * @return bool
64          */
65         public function delete($key);
66
67         /**
68          * Remove outdated data from the cache
69          * @param  boolean $outdated just remove outdated values
70          *
71          * @return bool
72          */
73         public function clear($outdated = true);
74
75         /**
76          * Returns the name of the current cache
77          *
78          * @return string
79          */
80         public function getName();
81 }