<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
*/
class CRM_Utils_Cache_APCcache {
const DEFAULT_TIMEOUT = 3600;
- const DEFAULT_PREFIX = '';
+ const DEFAULT_PREFIX = '';
/**
- * The default timeout to use
+ * The default timeout to use.
*
* @var int
*/
protected $_prefix = self::DEFAULT_PREFIX;
/**
- * Constructor
+ * Constructor.
*
- * @param array $config an array of configuration params
+ * @param array $config
+ * An array of configuration params.
*
* @return \CRM_Utils_Cache_APCcache
*/
- function __construct(&$config) {
+ public function __construct(&$config) {
if (isset($config['timeout'])) {
$this->_timeout = intval($config['timeout']);
}
*
* @return bool
*/
- function set($key, &$value) {
+ public function set($key, &$value) {
if (!apc_store($this->_prefix . $key, $value, $this->_timeout)) {
return FALSE;
}
*
* @return mixed
*/
- function &get($key) {
+ public function &get($key) {
return apc_fetch($this->_prefix . $key);
}
*
* @return bool|string[]
*/
- function delete($key) {
+ public function delete($key) {
return apc_delete($this->_prefix . $key);
}
- function flush() {
+ public function flush() {
$allinfo = apc_cache_info('user');
$keys = $allinfo['cache_list'];
$prefix = $this->_prefix . "CRM_"; // Our keys follows this pattern: ([A-Za-z0-9_]+)?CRM_[A-Za-z0-9_]+
foreach ($keys as $key) {
$name = $key['info'];
- if ($prefix == substr($name,0,$lp)) { // Ours?
+ if ($prefix == substr($name, 0, $lp)) {
+ // Ours?
apc_delete($this->_prefix . $name);
}
}
}
+
}