Example #1
0
 function remove($key)
 {
     if (!ini_get('xcache.var_size')) {
         return;
     }
     return @xcache_unset($key);
 }
 public function delete($id, $tag = FALSE)
 {
     if ($tag !== FALSE) {
         Kohana::log('error', 'Cache: tags are unsupported by the Xcache driver');
         return TRUE;
     } elseif ($id !== TRUE) {
         if (xcache_isset($id)) {
             return xcache_unset($id);
         }
         return FALSE;
     } else {
         // Do the login
         $this->auth();
         $result = TRUE;
         for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) {
             if (xcache_clear_cache(XC_TYPE_VAR, $i) !== NULL) {
                 $result = FALSE;
                 break;
             }
         }
         // Undo the login
         $this->auth(TRUE);
         return $result;
     }
     return TRUE;
 }
Example #3
0
function xp_unset($var)
{
    if (XCACHE_ENABLED) {
        xcache_unset(XCACHE_PREFIX . $var);
    }
    unlink("./cache/" . XCACHE_PREFIX . $var);
}
Example #4
0
 function clean($basedir, $initdir = false, $filename = false)
 {
     if (strlen($filename)) {
         $basedir_version = xcache_get($this->sid . $basedir);
         if ($basedir_version === null) {
             return true;
         }
         if ($initdir !== false) {
             $initdir_version = xcache_get($basedir_version . "|" . $initdir);
             if ($initdir_version === null) {
                 return true;
             }
         } else {
             $initdir_version = "";
         }
         xcache_unset($basedir_version . "|" . $initdir_version . "|" . $filename);
     } else {
         if (strlen($initdir)) {
             $basedir_version = xcache_get($this->sid . $basedir);
             if ($basedir_version === null) {
                 return true;
             }
             xcache_unset($basedir_version . "|" . $initdir);
         } else {
             xcache_unset($this->sid . $basedir);
         }
     }
     return true;
 }
 /**
  * @param string $key
  * @return boolean
  */
 public function delete($key)
 {
     if (!xcache_isset($key)) {
         return TRUE;
     }
     return xcache_unset($key);
 }
Example #6
0
 /**
  * Check for extension availability and perform cleanup.
  */
 protected function setUp()
 {
     if (!extension_loaded('xcache')) {
         $this->markTestSkipped('XCache extension not available.');
     }
     xcache_unset('test');
 }
Example #7
0
 /**
  * Delete cache from shared memory
  *
  * @param  string $sKey - file name
  * @return result of the operation
  */
 function delData($sKey)
 {
     if (!xcache_isset($sKey)) {
         return true;
     }
     return xcache_unset($sKey);
 }
Example #8
0
 /**
  */
 function del($name)
 {
     if (!$this->is_ready()) {
         return null;
     }
     return xcache_unset($name);
 }
Example #9
0
 /**
  * Destroy a session
  *
  * @param   integer  $session_id  The session ID being destroyed
  *
  * @return  boolean  True on success, false otherwise
  *
  * @since   __DEPLOY_VERSION__
  */
 public function destroy($session_id)
 {
     if (!xcache_isset($this->prefix . $session_id)) {
         return true;
     }
     return xcache_unset($this->prefix . $session_id);
 }
Example #10
0
 public function delete($key)
 {
     if (!$key) {
         return false;
     }
     return xcache_unset($key);
 }
Example #11
0
function cs_cache_delete($name, $ttl = 0)
{
    $token = empty($ttl) ? $name : 'ttl_' . $name;
    if (xcache_isset($token)) {
        xcache_unset($token);
    }
}
Example #12
0
 /**
  * Remove a cached data entry by id and group
  *
  * @access	public
  * @param	string	$id		The cache data id
  * @param	string	$group	The cache data group
  * @return	boolean	True on success, false otherwise
  * @since	1.5
  */
 function remove($id, $group)
 {
     $cache_id = $this->_getCacheId($id, $group);
     if (!xcache_isset($cache_id)) {
         return true;
     }
     return xcache_unset($cache_id);
 }
Example #13
0
 /**
  * (Plug-in replacement for memcache API) Delete data from the persistant cache.
  *
  * @param  mixed			Key name
  */
 function delete($key)
 {
     // Update list of e-objects
     global $ECACHE_OBJECTS;
     unset($ECACHE_OBJECTS[$key]);
     xcache_set(get_file_base() . 'ECACHE_OBJECTS', $ECACHE_OBJECTS, 0);
     xcache_unset($key);
 }
 /**
  * Destroy the data for a particular session identifier in the SessionHandler backend.
  *
  * @param   string  $id  The session identifier.
  *
  * @return  boolean  True on success, false otherwise.
  *
  * @since   11.1
  */
 public function destroy($id)
 {
     $sess_id = 'sess_' . $id;
     if (!xcache_isset($sess_id)) {
         return true;
     }
     return xcache_unset($sess_id);
 }
Example #15
0
 public function clear($tags)
 {
     $tags = (array) $this->_mapTags($tags);
     foreach ($tags as $tag) {
         xcache_unset($tag);
     }
     return true;
 }
Example #16
0
 /**
  * Sets a value to the variable store
  * @param string $key The key of the variable
  * @param mixed $value The value of the variable
  * @param integer $timeToLive Set to a number of seconds to make the variable expire in that amount of time
  * @return null
  */
 public function set($key, $value = null, $timeToLive = null)
 {
     if ($value === null) {
         xcache_unset($key);
     } else {
         xcache_set($key, $value, $timeToLive);
     }
 }
Example #17
0
 /**
  * Delete cache item by key
  */
 public function delete($keys)
 {
     foreach ($keys as $key) {
         if (!xcache_unset($key)) {
             return NO;
         }
     }
     return YES;
 }
Example #18
0
 /**
  * Delete cache item by key
  */
 public function delete($keys)
 {
     foreach ($keys as $key) {
         if (!xcache_unset($key)) {
             return FALSE;
         }
     }
     return TRUE;
 }
Example #19
0
 function delete($key)
 {
     $key = $this->key($key);
     if (function_exists('apc_delete')) {
         return apc_delete($key);
     }
     if (function_exists('xcache_unset')) {
         return xcache_unset($key);
     }
 }
Example #20
0
 public function _before(UnitTester $I)
 {
     if (!function_exists('xcache_emulation') && !function_exists('xcache_get')) {
         throw new \PHPUnit_Framework_SkippedTestError('Warning: xcache extension is not loaded');
     }
     $I->haveServiceInDi('modelsMetadata', function () {
         return new Xcache(['prefix' => 'app\\', 'lifetime' => 60]);
     }, true);
     $this->data = (require PATH_FIXTURES . 'metadata/robots.php');
     xcache_unset('$PMM$app\\');
 }
Example #21
0
 function clean()
 {
     foreach ($this->known_items as $title => $script_name) {
         $this->cur_query = "cache->rm('{$title}')";
         $this->debug('start');
         $this->debug('stop');
         $this->cur_query = null;
         $this->num_queries++;
         xcache_unset($this->prefix . $title);
     }
 }
Example #22
0
 public function clean($group, $mode = null)
 {
     $allinfo = xcache_list(XC_TYPE_VAR, 0);
     $keys = $allinfo['cache_list'];
     $secret = $this->_hash;
     foreach ($keys as $key) {
         if (strpos($key['name'], $secret . '-cache-' . $group . '-') === 0 xor $mode != 'group') {
             xcache_unset($key['name']);
         }
     }
     return true;
 }
Example #23
0
 public static function getCache()
 {
     // return false;
     // clearstatcache();
     $request = new Typecho_Request();
     if ($request->isPost()) {
         // 提交评论时,即有新评论收到时会先清空本文章缓存
         $file_path = str_replace('/comment', '', $request->getPathinfo());
         $file_name = md5($file_path);
         // xcache_set('TEST', $file_path);
         // xcache_set('TEST2', $file_name);
         xcache_unset('Typecho_cache_' . $file_name);
         // 	if (file_exists($file_path)) {
         // 		@chmod($file_path, 0777);
         // 		@unlink($file_path);
         // 	}
         // 	// echo $file_path;
         // echo 1;
     } else {
         // $file_name = md5($request->getPathinfo());
         // var_dump($request);
         // 评论
         $file_name = md5(preg_replace('/(.*)(\\/comment.*)/i', '$1', $request->getPathinfo()));
         if (xcache_isset('Typecho_cache_' . $file_name)) {
             // xcache_set('Typecho_cache_' . $file_name, ob_get_contents(), 600);
             echo xcache_get('Typecho_cache_' . $file_name);
             exit;
         }
         // ob_start();
         // echo '12313';
         // 	$file_path = self::getPath($request->getPathinfo());
         // 	if (file_exists($file_path)) {
         // 		if (self::isValid($file_path)) {
         // 			$handle = @fopen($file_path, 'rb');
         // 			if (@flock($handle, LOCK_SH | LOCK_NB)) {
         // 				fpassthru($handle);
         // 				flock($handle, LOCK_UN);
         // 				fclose($handle);
         // 				exit;
         // 			}
         // 			echo "string2";
         // 			fclose($handle);
         // 		} else {
         // 			@chmod($file_path, 0777);
         // 			@unlink($file_path);
         // 			echo "string3";
         // 		}
         // 	}
     }
 }
Example #24
0
 function rm($name = '')
 {
     if ($name) {
         $this->cur_query = "cache->rm('{$name}')";
         $this->debug('start');
         $this->debug('stop');
         $this->cur_query = null;
         $this->num_queries++;
         return xcache_unset($this->prefix . $name);
     } else {
         xcache_clear_cache(XC_TYPE_PHP, 0);
         xcache_clear_cache(XC_TYPE_VAR, 0);
         return;
     }
 }
Example #25
0
 /**
  * {@inheritDoc}
  */
 public function flush($namespace = null)
 {
     $namespace = null !== $namespace ? implode($this->getNamespaceDelimiter(), (array) $namespace) : null;
     for ($ii = 0, $max = xcache_count(XC_TYPE_VAR); $ii < $max; ++$ii) {
         $block = xcache_list(XC_TYPE_VAR, $ii);
         foreach ($block as $entries) {
             foreach ($entries as $entry) {
                 if (!$namespace || 0 === strpos($entry['name'], $namespace)) {
                     xcache_unset($entry['name']);
                 }
             }
         }
     }
     return true;
 }
 /**
  * {@inheritdoc}
  */
 function loadClass($class)
 {
     // Look if the cache has anything for this class.
     if (xcache_isset($this->prefix . $class) && ($file = xcache_get($this->prefix . $class))) {
         if (is_file($file)) {
             require $file;
             return;
         }
         xcache_unset($this->prefix . $class);
     }
     // Resolve cache miss.
     $api = new LoadClassGetFileInjectedApi($class);
     if ($this->finder->apiFindFile($api, $class)) {
         xcache_set($this->prefix . $class, $api->getFile());
     }
 }
Example #27
0
 /**
  * Flush the cache.
  */
 function flush()
 {
     $prefix = INDEX_FILE_LOCATION . ':' . $this->getContext() . ':' . $this->getCacheId();
     if (function_exists('xcache_unset_by_prefix')) {
         // If possible, just flush the context
         xcache_unset_by_prefix(prefix);
     } else {
         // Otherwise, we need to do this manually
         for ($i = 0; $i < xcache_count(XC_TYPE_VAR); $i++) {
             $cache = xcache_list(XC_TYPE_VAR, $i);
             foreach ($cache['cache_list'] as $entry) {
                 if (substr($entry['name'], 0, strlen($prefix)) == $prefix) {
                     xcache_unset($entry['name']);
                 }
             }
         }
     }
 }
Example #28
0
 function Delete($var)
 {
     global $site_config;
     switch ($this->type) {
         case "memcache":
             return $this->obj->delete($site_config['SITENAME'] . "_" . $var);
             break;
         case "apc":
             return apc_delete($var);
             break;
         case "disk":
             @unlink($this->cachedir . "/{$var}.cache");
             break;
         case "xcache":
             return xcache_unset($var);
             break;
     }
 }
Example #29
0
 public function delete($key)
 {
     return xcache_unset($key);
 }
Example #30
0
 /**
  * @see sfCache
  */
 public function removePattern($pattern)
 {
     $this->checkAuth();
     $regexp = self::patternToRegexp($this->getOption('prefix') . $pattern);
     for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) {
         $infos = xcache_list(XC_TYPE_VAR, $i);
         if (!is_array($infos['cache_list'])) {
             return;
         }
         foreach ($infos['cache_list'] as $info) {
             if (preg_match($regexp, $info['name'])) {
                 xcache_unset($info['name']);
             }
         }
     }
 }