Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-07-22 04:23:24 +0400
committerRobin Appelman <icewind@owncloud.com>2012-07-22 04:23:24 +0400
commit2b747789588e34bce24bd558f7e979a6e0ea8047 (patch)
treefded811275248d9842f4a7c0d5a46b5f778784d8 /lib/cache.php
parent2a73678fef47f8230f6caf546e42b22d722973b0 (diff)
add method to OC_Cache to check whether a fast cache (apc/xdebug/etc) is available
Diffstat (limited to 'lib/cache.php')
-rw-r--r--lib/cache.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/cache.php b/lib/cache.php
index 1f269174fad..6f4b3e6e3f6 100644
--- a/lib/cache.php
+++ b/lib/cache.php
@@ -7,9 +7,20 @@
*/
class OC_Cache {
+ /**
+ * @var OC_Cache $user_cache
+ */
static protected $user_cache;
+ /**
+ * @var OC_Cache $global_cache
+ */
static protected $global_cache;
+ static protected $isFast=null;
+ /**
+ * get the global cache
+ * @return OC_Cache
+ */
static public function getGlobalCache() {
if (!self::$global_cache) {
$fast_cache = null;
@@ -27,6 +38,10 @@ class OC_Cache {
return self::$global_cache;
}
+ /**
+ * get the user cache
+ * @return OC_Cache
+ */
static public function getUserCache() {
if (!self::$user_cache) {
$fast_cache = null;
@@ -44,11 +59,19 @@ class OC_Cache {
return self::$user_cache;
}
+ /**
+ * get a value from the user cache
+ * @return mixed
+ */
static public function get($key) {
$user_cache = self::getUserCache();
return $user_cache->get($key);
}
+ /**
+ * set a value in the user cache
+ * @return bool
+ */
static public function set($key, $value, $ttl=0) {
if (empty($key)) {
return false;
@@ -57,19 +80,42 @@ class OC_Cache {
return $user_cache->set($key, $value, $ttl);
}
+ /**
+ * check if a value is set in the user cache
+ * @return bool
+ */
static public function hasKey($key) {
$user_cache = self::getUserCache();
return $user_cache->hasKey($key);
}
+ /**
+ * remove an item from the user cache
+ * @return bool
+ */
static public function remove($key) {
$user_cache = self::getUserCache();
return $user_cache->remove($key);
}
+ /**
+ * clear the user cache
+ * @return bool
+ */
static public function clear() {
$user_cache = self::getUserCache();
return $user_cache->clear();
}
+ /**
+ * check if a fast memory based cache is available
+ * @return true
+ */
+ static public function isFast() {
+ if(is_null(self::$isFast)){
+ self::$isFast=function_exists('xcache_set') || function_exists('apc_store');
+ }
+ return self::$isFast;
+ }
+
}