1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
5 * An open source application development framework for PHP 5.1.6 or newer
8 * @author ExpressionEngine Dev Team
9 * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc.
10 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
16 // ------------------------------------------------------------------------
19 * CodeIgniter APC Caching Class
21 * @package CodeIgniter
22 * @subpackage Libraries
24 * @author ExpressionEngine Dev Team
28 class CI_Cache_apc extends CI_Driver {
33 * Look for a value in the cache. If it exists, return the data
34 * if not, return FALSE
37 * @return mixed value that is stored/FALSE on failure
39 public function get($id)
41 $data = apc_fetch($id);
43 return (is_array($data)) ? $data[0] : FALSE;
46 // ------------------------------------------------------------------------
51 * @param string Unique Key
52 * @param mixed Data to store
53 * @param int Length of time (in seconds) to cache the data
55 * @return boolean true on success/false on failure
57 public function save($id, $data, $ttl = 60)
59 return apc_store($id, array($data, time(), $ttl), $ttl);
62 // ------------------------------------------------------------------------
67 * @param mixed unique identifier of the item in the cache
68 * @param boolean true on success/false on failure
70 public function delete($id)
72 return apc_delete($id);
75 // ------------------------------------------------------------------------
80 * @return boolean false on failure/true on success
82 public function clean()
84 return apc_clear_cache('user');
87 // ------------------------------------------------------------------------
92 * @param string user/filehits
93 * @return mixed array on success, false on failure
95 public function cache_info($type = NULL)
97 return apc_cache_info($type);
100 // ------------------------------------------------------------------------
105 * @param mixed key to get cache metadata on
106 * @return mixed array on success/false on failure
108 public function get_metadata($id)
110 $stored = apc_fetch($id);
112 if (count($stored) !== 3)
117 list($data, $time, $ttl) = $stored;
120 'expire' => $time + $ttl,
126 // ------------------------------------------------------------------------
131 * Check to see if APC is available on this system, bail if it isn't.
133 public function is_supported()
135 if ( ! extension_loaded('apc') OR ! function_exists('apc_store'))
137 log_message('error', 'The APC PHP extension must be loaded to use APC Cache.');
144 // ------------------------------------------------------------------------
150 /* End of file Cache_apc.php */
151 /* Location: ./system/libraries/Cache/drivers/Cache_apc.php */