mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 18:19:22 +03:00
v1.2.12.435
This commit is contained in:
parent
513936e5f7
commit
93e620e3de
399 changed files with 765 additions and 687 deletions
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Cache\Drivers;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Cache
|
||||
* @subpackage Drivers
|
||||
*/
|
||||
class APC implements \MailSo\Cache\DriverInterface
|
||||
{
|
||||
/**
|
||||
* @return \MailSo\Cache\Drivers\APC
|
||||
*/
|
||||
public static function NewInstance()
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sKey
|
||||
* @param string $sValue
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function Set($sKey, $sValue)
|
||||
{
|
||||
return \apc_store($this->generateCachedKey($sKey), (string) $sValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sKey
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function Get($sKey)
|
||||
{
|
||||
$sValue = \apc_fetch($this->generateCachedKey($sKey));
|
||||
return \is_string($sValue) ? $sValue : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sKey
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function Delete($sKey)
|
||||
{
|
||||
\apc_delete($this->generateCachedKey($sKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iTimeToClearInHours = 24
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function GC($iTimeToClearInHours = 24)
|
||||
{
|
||||
if (0 === $iTimeToClearInHours)
|
||||
{
|
||||
return \apc_clear_cache('user');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sKey
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function generateCachedKey($sKey)
|
||||
{
|
||||
return \sha1($sKey);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue