maison_alexandra/www/system-brs-core/library/cApc/cCacheHelper.php

42 lines
852 B
PHP

<?php
namespace BRSystems\Core\Library\cApc;
/**
* Generic APC cache helper.
*/
class cCacheHelper
{
/** @var cApc */
private $apc;
public function __construct(cApc $apc)
{
$this->apc = $apc;
}
public function key($type, $langId): string
{
if (is_array($type)) {
$type = implode('_', $type);
}
return $type . '_LANG_' . (int)$langId;
}
public function get($type, $langId)
{
return $this->apc->check($this->key($type, $langId));
}
public function store($type, $langId, $data, $ttl = null): bool
{
return $this->apc->store($this->key($type, $langId), $data, ($ttl !== null ? (int)$ttl : false));
}
public function delete($type, $langId): bool
{
return $this->apc->setExpired($this->key($type, $langId));
}
}