69 lines
1.6 KiB
PHP
Raw Normal View History

2017-08-30 11:37:48 +02:00
<?php
/**
* TNT OFFICIAL MODULE FOR PRESTASHOP
*
* @author GFI Informatique <www.gfi.fr>
* @copyright 2016-2017 GFI Informatique, 2016-2017 TNT
* @license https://opensource.org/licenses/MIT MIT License
*/
class TNTOfficiel_Cache
{
/**
* @param $strArgKey
* @return bool
*/
public static function isStored($strArgKey)
{
$objCache = Cache::getInstance();
$boolExistL1 = Cache::isStored($strArgKey);
$boolExistL2 = false;
if (_PS_CACHE_ENABLED_ && !$boolExistL1) {
$boolExistL2 = $objCache->exists($strArgKey);
}
return $boolExistL1 || $boolExistL2;
}
/**
* @param $strArgKey
* @param $mxdArgValue
* @param $intArgTTL
* @return bool
*/
public static function store($strArgKey, $mxdArgValue, $intArgTTL)
{
$objCache = Cache::getInstance();
$boolSetL1 = Cache::store($strArgKey, $mxdArgValue);
$boolSetL2 = true;
if (_PS_CACHE_ENABLED_) {
$boolSetL2 = $objCache->set($strArgKey, $mxdArgValue, $intArgTTL);
}
return $boolSetL1 && $boolSetL2;
}
/**
* @param $strArgKey
* @return null
*/
public static function retrieve($strArgKey)
{
$objCache = Cache::getInstance();
$mxdGet = null;
if (Cache::isStored($strArgKey)) {
$mxdGet = Cache::retrieve($strArgKey);
}
elseif (_PS_CACHE_ENABLED_ && $objCache->exists($strArgKey)) {
$mxdGet = $objCache->get($strArgKey);
}
return $mxdGet;
}
}