first commit
This commit is contained in:
41
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/auryn/lib/ReflectionCacheApc.php
vendored
Normal file
41
wp-content/plugins/sitepress-multilingual-cms/vendor/otgs/auryn/lib/ReflectionCacheApc.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace WPML\Auryn;
|
||||
|
||||
class ReflectionCacheApc implements ReflectionCache
|
||||
{
|
||||
private $localCache;
|
||||
private $timeToLive = 5;
|
||||
|
||||
public function __construct(ReflectionCache $localCache = null)
|
||||
{
|
||||
$this->localCache = $localCache ?: new ReflectionCacheArray;
|
||||
}
|
||||
|
||||
public function setTimeToLive($seconds)
|
||||
{
|
||||
$seconds = (int) $seconds;
|
||||
$this->timeToLive = ($seconds > 0) ? $seconds : $this->timeToLive;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fetch($key)
|
||||
{
|
||||
$localData = $this->localCache->fetch($key);
|
||||
|
||||
if ($localData != false) {
|
||||
return $localData;
|
||||
} else {
|
||||
$success = null; // stupid by-ref parameter that scrutinizer complains about
|
||||
$data = apc_fetch($key, $success);
|
||||
return $success ? $data : false;
|
||||
}
|
||||
}
|
||||
|
||||
public function store($key, $data)
|
||||
{
|
||||
$this->localCache->store($key, $data);
|
||||
apc_store($key, $data, $this->timeToLive);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user