]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Cache.php
Merge pull request #5862 from nupplaphil/rename_App_Methods
[friendica.git] / src / Core / Cache.php
index 68537c5249c955597d1ce3026e0865d4792a389c..0fb328aaee8368f86c3e1ec3fbbc2853e453592e 100644 (file)
@@ -23,13 +23,15 @@ class Cache extends \Friendica\BaseObject
        /**
         * @var Cache\ICacheDriver
         */
-       private static $driver = null;
+       private static $driver       = null;
+       public  static $driver_class = null;
+       public  static $driver_name  = null;
 
        public static function init()
        {
-               $driver_name = Config::get('system', 'cache_driver', 'database');
-
-               self::$driver = CacheDriverFactory::create($driver_name);
+               self::$driver_name  = Config::get('system', 'cache_driver', 'database');
+               self::$driver       = CacheDriverFactory::create(self::$driver_name);
+               self::$driver_class = get_class(self::$driver);
        }
 
        /**
@@ -49,22 +51,17 @@ class Cache extends \Friendica\BaseObject
        /**
         * @brief Returns all the cache keys sorted alphabetically
         *
-        * @return array|null Null if the driver doesn't support this feature
+        * @param string $prefix Prefix of the keys (optional)
+        *
+        * @return array Empty if the driver doesn't support this feature
         */
-       public static function getAllKeys()
+       public static function getAllKeys($prefix = null)
        {
                $time = microtime(true);
 
-               $return = self::getDriver()->getAllKeys();
-
-               // Keys are prefixed with the node hostname, let's remove it
-               array_walk($return, function (&$value) {
-                       $value = preg_replace('/^' . self::getApp()->get_hostname() . ':/', '', $value);
-               });
-
-               sort($return);
+               $return = self::getDriver()->getAllKeys($prefix);
 
-               self::getApp()->save_timestamp($time, 'cache');
+               self::getApp()->saveTimestamp($time, 'cache');
 
                return $return;
        }
@@ -82,7 +79,7 @@ class Cache extends \Friendica\BaseObject
 
                $return = self::getDriver()->get($key);
 
-               self::getApp()->save_timestamp($time, 'cache');
+               self::getApp()->saveTimestamp($time, 'cache');
 
                return $return;
        }
@@ -104,7 +101,7 @@ class Cache extends \Friendica\BaseObject
 
                $return = self::getDriver()->set($key, $value, $duration);
 
-               self::getApp()->save_timestamp($time, 'cache_write');
+               self::getApp()->saveTimestamp($time, 'cache_write');
 
                return $return;
        }
@@ -122,7 +119,7 @@ class Cache extends \Friendica\BaseObject
 
                $return = self::getDriver()->delete($key);
 
-               self::getApp()->save_timestamp($time, 'cache_write');
+               self::getApp()->saveTimestamp($time, 'cache_write');
 
                return $return;
        }