summaryrefslogtreecommitdiff
path: root/kohana/libraries/drivers/Cache/Eaccelerator.php
blob: a45616d54b11b77b53b9dc8a0584616525a77669 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
 * Eaccelerator-based Cache driver.
 *
 * $Id: Eaccelerator.php 4046 2009-03-05 19:23:29Z Shadowhand $
 *
 * @package    Cache
 * @author     Kohana Team
 * @copyright  (c) 2007-2008 Kohana Team
 * @license    http://kohanaphp.com/license.html
 */
class Cache_Eaccelerator_Driver implements Cache_Driver {

	public function __construct()
	{
		if ( ! extension_loaded('eaccelerator'))
			throw new Kohana_Exception('cache.extension_not_loaded', 'eaccelerator');
	}

	public function get($id)
	{
		return eaccelerator_get($id);
	}

	public function find($tag)
	{
		Kohana::log('error', 'tags are unsupported by the eAccelerator driver');

		return array();
	}

	public function set($id, $data, array $tags = NULL, $lifetime)
	{
		if ( ! empty($tags))
		{
			Kohana::log('error', 'tags are unsupported by the eAccelerator driver');
		}

		return eaccelerator_put($id, $data, $lifetime);
	}

	public function delete($id, $tag = FALSE)
	{
		if ($tag === TRUE)
		{
			Kohana::log('error', 'tags are unsupported by the eAccelerator driver');
			return FALSE;
		}
		elseif ($id === TRUE)
		{
			return eaccelerator_clean();
		}
		else
		{
			return eaccelerator_rm($id);
		}
	}

	public function delete_expired()
	{
		eaccelerator_gc();

		return TRUE;
	}

} // End Cache eAccelerator Driver