1 <?php defined('SYSPATH') OR die('No direct access allowed.');
5 * $Id: Xcache.php 4046 2009-03-05 19:23:29Z Shadowhand $
9 * @copyright (c) 2007-2008 Kohana Team
10 * @license http://kohanaphp.com/license.html
12 class Cache_Xcache_Driver implements Cache_Driver {
14 public function __construct()
16 if ( ! extension_loaded('xcache'))
17 throw new Kohana_Exception('cache.extension_not_loaded', 'xcache');
20 public function get($id)
22 if (xcache_isset($id))
23 return xcache_get($id);
28 public function set($id, $data, array $tags = NULL, $lifetime)
32 Kohana::log('error', 'Cache: tags are unsupported by the Xcache driver');
35 return xcache_set($id, $data, $lifetime);
38 public function find($tag)
40 Kohana::log('error', 'Cache: tags are unsupported by the Xcache driver');
44 public function delete($id, $tag = FALSE)
48 Kohana::log('error', 'Cache: tags are unsupported by the Xcache driver');
53 if (xcache_isset($id))
54 return xcache_unset($id);
63 for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++)
65 if (xcache_clear_cache(XC_TYPE_VAR, $i) !== NULL)
80 public function delete_expired()
85 private function auth($reverse = FALSE)
87 static $backup = array();
89 $keys = array('PHP_AUTH_USER', 'PHP_AUTH_PW');
91 foreach ($keys as $key)
95 if (isset($backup[$key]))
97 $_SERVER[$key] = $backup[$key];
102 unset($_SERVER[$key]);
107 $value = getenv($key);
109 if ( ! empty($value))
111 $backup[$key] = $value;
114 $_SERVER[$key] = Kohana::config('cache_xcache.'.$key);
119 } // End Cache Xcache Driver