From 80a3f8d066b7deffe70a232ca956746db02db138 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 17 Mar 2013 16:00:39 +0100 Subject: Seperate memory based cache from OC_Cache --- lib/cache/apc.php | 64 ---------------------------------------------------- lib/cache/xcache.php | 56 --------------------------------------------- 2 files changed, 120 deletions(-) delete mode 100644 lib/cache/apc.php delete mode 100644 lib/cache/xcache.php (limited to 'lib/cache') diff --git a/lib/cache/apc.php b/lib/cache/apc.php deleted file mode 100644 index 895d307ea26..00000000000 --- a/lib/cache/apc.php +++ /dev/null @@ -1,64 +0,0 @@ - - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -class OC_Cache_APC { - protected $prefix; - - public function __construct($global = false) { - $this->prefix = OC_Util::getInstanceId().'/'; - if (!$global) { - $this->prefix .= OC_User::getUser().'/'; - } - } - - /** - * entries in APC gets namespaced to prevent collisions between owncloud instances and users - */ - protected function getNameSpace() { - return $this->prefix; - } - - public function get($key) { - $result = apc_fetch($this->getNamespace().$key, $success); - if (!$success) { - return null; - } - return $result; - } - - public function set($key, $value, $ttl=0) { - return apc_store($this->getNamespace().$key, $value, $ttl); - } - - public function hasKey($key) { - return apc_exists($this->getNamespace().$key); - } - - public function remove($key) { - return apc_delete($this->getNamespace().$key); - } - - public function clear($prefix='') { - $ns = $this->getNamespace().$prefix; - $cache = apc_cache_info('user'); - foreach($cache['cache_list'] as $entry) { - if (strpos($entry['info'], $ns) === 0) { - apc_delete($entry['info']); - } - } - return true; - } -} -if(!function_exists('apc_exists')) { - function apc_exists($keys) - { - $result=false; - apc_fetch($keys, $result); - return $result; - } -} diff --git a/lib/cache/xcache.php b/lib/cache/xcache.php deleted file mode 100644 index 9f380f870b9..00000000000 --- a/lib/cache/xcache.php +++ /dev/null @@ -1,56 +0,0 @@ - - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -class OC_Cache_XCache { - protected $prefix; - - public function __construct($global = false) { - $this->prefix = OC_Util::getInstanceId().'/'; - if (!$global) { - $this->prefix .= OC_User::getUser().'/'; - } - } - - /** - * entries in XCache gets namespaced to prevent collisions between owncloud instances and users - */ - protected function getNameSpace() { - return $this->prefix; - } - - public function get($key) { - return xcache_get($this->getNamespace().$key); - } - - public function set($key, $value, $ttl=0) { - if($ttl>0) { - return xcache_set($this->getNamespace().$key, $value, $ttl); - }else{ - return xcache_set($this->getNamespace().$key, $value); - } - } - - public function hasKey($key) { - return xcache_isset($this->getNamespace().$key); - } - - public function remove($key) { - return xcache_unset($this->getNamespace().$key); - } - - public function clear($prefix='') { - if(!function_exists('xcache_unset_by_prefix')) { - function xcache_unset_by_prefix($prefix) { - // Since we can't clear targetted cache, we'll clear all. :( - xcache_clear_cache(XC_TYPE_VAR, 0); - } - } - xcache_unset_by_prefix($this->getNamespace().$prefix); - return true; - } -} -- cgit v1.2.3