Initial Kohana install
[speedfreak] / Server / system / libraries / drivers / Cache / Apc.php
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 /**
3  * APC-based Cache driver.
4  *
5  * $Id: Apc.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_Apc_Driver implements Cache_Driver {
13
14         public function __construct()
15         {
16                 if ( ! extension_loaded('apc'))
17                         throw new Kohana_Exception('cache.extension_not_loaded', 'apc');
18         }
19
20         public function get($id)
21         {
22                 return (($return = apc_fetch($id)) === FALSE) ? NULL : $return;
23         }
24
25         public function set($id, $data, array $tags = NULL, $lifetime)
26         {
27                 if ( ! empty($tags))
28                 {
29                         Kohana::log('error', 'Cache: tags are unsupported by the APC driver');
30                 }
31
32                 return apc_store($id, $data, $lifetime);
33         }
34
35         public function find($tag)
36         {
37                 Kohana::log('error', 'Cache: tags are unsupported by the APC driver');
38
39                 return array();
40         }
41
42         public function delete($id, $tag = FALSE)
43         {
44                 if ($tag === TRUE)
45                 {
46                         Kohana::log('error', 'Cache: tags are unsupported by the APC driver');
47                         return FALSE;
48                 }
49                 elseif ($id === TRUE)
50                 {
51                         return apc_clear_cache('user');
52                 }
53                 else
54                 {
55                         return apc_delete($id);
56                 }
57         }
58
59         public function delete_expired()
60         {
61                 return TRUE;
62         }
63
64 } // End Cache APC Driver