a45616d54b11b77b53b9dc8a0584616525a77669
[speedfreak] / Server / system / libraries / drivers / Cache / Eaccelerator.php
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 /**
3  * Eaccelerator-based Cache driver.
4  *
5  * $Id: Eaccelerator.php 4046 2009-03-05 19:23:29Z Shadowhand $
6  *
7  * @package    Cache
8  * @author     Kohana Team
9  * @copyright  (c) 2007-2008 Kohana Team
10  * @license    http://kohanaphp.com/license.html
11  */
12 class Cache_Eaccelerator_Driver implements Cache_Driver {
13
14         public function __construct()
15         {
16                 if ( ! extension_loaded('eaccelerator'))
17                         throw new Kohana_Exception('cache.extension_not_loaded', 'eaccelerator');
18         }
19
20         public function get($id)
21         {
22                 return eaccelerator_get($id);
23         }
24
25         public function find($tag)
26         {
27                 Kohana::log('error', 'tags are unsupported by the eAccelerator driver');
28
29                 return array();
30         }
31
32         public function set($id, $data, array $tags = NULL, $lifetime)
33         {
34                 if ( ! empty($tags))
35                 {
36                         Kohana::log('error', 'tags are unsupported by the eAccelerator driver');
37                 }
38
39                 return eaccelerator_put($id, $data, $lifetime);
40         }
41
42         public function delete($id, $tag = FALSE)
43         {
44                 if ($tag === TRUE)
45                 {
46                         Kohana::log('error', 'tags are unsupported by the eAccelerator driver');
47                         return FALSE;
48                 }
49                 elseif ($id === TRUE)
50                 {
51                         return eaccelerator_clean();
52                 }
53                 else
54                 {
55                         return eaccelerator_rm($id);
56                 }
57         }
58
59         public function delete_expired()
60         {
61                 eaccelerator_gc();
62
63                 return TRUE;
64         }
65
66 } // End Cache eAccelerator Driver