]> git.mxchange.org Git - friendica.git/blob - src/Core/Cache/IMemoryCache.php
Merge pull request #7754 from annando/aria
[friendica.git] / src / Core / Cache / IMemoryCache.php
1 <?php
2
3 namespace Friendica\Core\Cache;
4
5 /**
6  * This interface defines methods for Memory-Caches only
7  *
8  * Interface IMemoryCache
9  *
10  * @package Friendica\Core\Cache
11  */
12 interface IMemoryCache extends ICache
13 {
14         /**
15          * Sets a value if it's not already stored
16          *
17          * @param string $key      The cache key
18          * @param mixed  $value    The old value we know from the cache
19          * @param int    $ttl      The cache lifespan, must be one of the Cache constants
20          * @return bool
21          */
22         public function add($key, $value, $ttl = Cache::FIVE_MINUTES);
23
24         /**
25          * Compares if the old value is set and sets the new value
26          *
27          * @param string $key         The cache key
28          * @param mixed  $oldValue    The old value we know from the cache
29          * @param mixed  $newValue    The new value we want to set
30          * @param int    $ttl             The cache lifespan, must be one of the Cache constants
31          *
32          * @return bool
33          */
34         public function compareSet($key, $oldValue, $newValue, $ttl = Cache::FIVE_MINUTES);
35
36         /**
37          * Compares if the old value is set and removes it
38          *
39          * @param string $key          The cache key
40          * @param mixed  $value        The old value we know and want to delete
41          * @return bool
42          */
43         public function compareDelete($key, $value);
44 }