1 <?php
defined('SYSPATH') OR die('No direct access allowed.');
5 * $Id: Xcache.php 3917 2009-01-21 03:06:22Z zombor $
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, $tags, $lifetime)
30 count($tags) and Kohana
::log('error', 'Cache: tags are unsupported by the Xcache driver');
32 return xcache_set($id, $data, $lifetime);
35 public function find($tag)
37 Kohana
::log('error', 'Cache: tags are unsupported by the Xcache driver');
41 public function delete($id, $tag = FALSE)
45 Kohana
::log('error', 'Cache: tags are unsupported by the Xcache driver');
50 if (xcache_isset($id))
51 return xcache_unset($id);
60 for ($i = 0, $max = xcache_count(XC_TYPE_VAR
); $i < $max; $i++
)
62 if (xcache_clear_cache(XC_TYPE_VAR
, $i) !== NULL)
77 public function delete_expired()
82 private function auth($reverse = FALSE)
84 static $backup = array();
86 $keys = array('PHP_AUTH_USER', 'PHP_AUTH_PW');
88 foreach ($keys as $key)
92 if (isset($backup[$key]))
94 $_SERVER[$key] = $backup[$key];
99 unset($_SERVER[$key]);
104 $value = getenv($key);
106 if ( ! empty($value))
108 $backup[$key] = $value;
111 $_SERVER[$key] = Kohana
::config('cache_xcache.'.$key);
116 } // End Cache Xcache Driver