Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../includes/Google/Cache
File: Apc.php
<?php
[0] Fix | Delete
/*
[1] Fix | Delete
* Copyright 2010 Google Inc.
[2] Fix | Delete
*
[3] Fix | Delete
* Licensed under the Apache License, Version 2.0 (the "License");
[4] Fix | Delete
* you may not use this file except in compliance with the License.
[5] Fix | Delete
* You may obtain a copy of the License at
[6] Fix | Delete
*
[7] Fix | Delete
* http://www.apache.org/licenses/LICENSE-2.0
[8] Fix | Delete
*
[9] Fix | Delete
* Unless required by applicable law or agreed to in writing, software
[10] Fix | Delete
* distributed under the License is distributed on an "AS IS" BASIS,
[11] Fix | Delete
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
[12] Fix | Delete
* See the License for the specific language governing permissions and
[13] Fix | Delete
* limitations under the License.
[14] Fix | Delete
*/
[15] Fix | Delete
[16] Fix | Delete
if (!class_exists('UDP_Google_Client')) {
[17] Fix | Delete
require_once dirname(__FILE__) . '/../autoload.php';
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* A persistent storage class based on the APC cache, which is not
[22] Fix | Delete
* really very persistent, as soon as you restart your web server
[23] Fix | Delete
* the storage will be wiped, however for debugging and/or speed
[24] Fix | Delete
* it can be useful, and cache is a lot cheaper then storage.
[25] Fix | Delete
*
[26] Fix | Delete
* @author Chris Chabot <chabotc@google.com>
[27] Fix | Delete
*/
[28] Fix | Delete
class Google_Cache_Apc extends Google_Cache_Abstract
[29] Fix | Delete
{
[30] Fix | Delete
/**
[31] Fix | Delete
* @var Google_Client the current client
[32] Fix | Delete
*/
[33] Fix | Delete
private $client;
[34] Fix | Delete
[35] Fix | Delete
public function __construct(UDP_Google_Client $client)
[36] Fix | Delete
{
[37] Fix | Delete
if (! function_exists('apc_add') ) {
[38] Fix | Delete
$error = "Apc functions not available";
[39] Fix | Delete
[40] Fix | Delete
$client->getLogger()->error($error);
[41] Fix | Delete
throw new Google_Cache_Exception($error);
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
$this->client = $client;
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* @inheritDoc
[49] Fix | Delete
*/
[50] Fix | Delete
public function get($key, $expiration = false)
[51] Fix | Delete
{
[52] Fix | Delete
$ret = apc_fetch($key);
[53] Fix | Delete
if ($ret === false) {
[54] Fix | Delete
$this->client->getLogger()->debug(
[55] Fix | Delete
'APC cache miss',
[56] Fix | Delete
array('key' => $key)
[57] Fix | Delete
);
[58] Fix | Delete
return false;
[59] Fix | Delete
}
[60] Fix | Delete
if (is_numeric($expiration) && (time() - $ret['time'] > $expiration)) {
[61] Fix | Delete
$this->client->getLogger()->debug(
[62] Fix | Delete
'APC cache miss (expired)',
[63] Fix | Delete
array('key' => $key, 'var' => $ret)
[64] Fix | Delete
);
[65] Fix | Delete
$this->delete($key);
[66] Fix | Delete
return false;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
$this->client->getLogger()->debug(
[70] Fix | Delete
'APC cache hit',
[71] Fix | Delete
array('key' => $key, 'var' => $ret)
[72] Fix | Delete
);
[73] Fix | Delete
[74] Fix | Delete
return $ret['data'];
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
/**
[78] Fix | Delete
* @inheritDoc
[79] Fix | Delete
*/
[80] Fix | Delete
public function set($key, $value)
[81] Fix | Delete
{
[82] Fix | Delete
$var = array('time' => time(), 'data' => $value);
[83] Fix | Delete
$rc = apc_store($key, $var);
[84] Fix | Delete
[85] Fix | Delete
if ($rc == false) {
[86] Fix | Delete
$this->client->getLogger()->error(
[87] Fix | Delete
'APC cache set failed',
[88] Fix | Delete
array('key' => $key, 'var' => $var)
[89] Fix | Delete
);
[90] Fix | Delete
throw new Google_Cache_Exception("Couldn't store data");
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
$this->client->getLogger()->debug(
[94] Fix | Delete
'APC cache set',
[95] Fix | Delete
array('key' => $key, 'var' => $var)
[96] Fix | Delete
);
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* @inheritDoc
[101] Fix | Delete
* @param String $key
[102] Fix | Delete
*/
[103] Fix | Delete
public function delete($key)
[104] Fix | Delete
{
[105] Fix | Delete
$this->client->getLogger()->debug(
[106] Fix | Delete
'APC cache delete',
[107] Fix | Delete
array('key' => $key)
[108] Fix | Delete
);
[109] Fix | Delete
apc_delete($key);
[110] Fix | Delete
}
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function