3 namespace Friendica\Core\Cache;
4 use Friendica\BaseObject;
8 * Abstract class for common used functions
10 * Class AbstractCacheDriver
12 * @package Friendica\Core\Cache
14 abstract class AbstractCacheDriver extends BaseObject
17 * @param string $key The original key
18 * @return string The cache key used for the cache
20 protected function getCacheKey($key)
22 // We fetch with the hostname as key to avoid problems with other applications
23 return self::getApp()->get_hostname() . ":" . $key;
27 * @param array $keys A list of cached keys
28 * @return array A list of original keys
30 protected function getOriginalKeys($keys)
35 // Keys are prefixed with the node hostname, let's remove it
36 array_walk($keys, function (&$value) {
37 $value = preg_replace('/^' . self::getApp()->get_hostname() . ':/', '', $value);
47 * Filters a list for a given prefix
49 * @param array $list the list
50 * @param string|null $prefix the prefix
52 * @return array the filtered list
54 protected function filterPrefix($list, $prefix = null)
57 return array_keys($list);
61 foreach (array_keys($list) as $key) {
62 if (strpos($key, $prefix) === 0) {
63 array_push($result, $key);