straightsoft / contao-database_cache
此模块提供了将请求数据缓存到数据库的功能。
1.0.6
2017-12-01 15:29 UTC
Requires
- php: ~5.4 || ~7.0
- contao-community-alliance/composer-plugin: ~2.4 || ~3.0
- contao/core-bundle: ^3.5.1 || ~4.1
- heimrichhannot/contao-haste_plus: ~1.6
This package is not auto-updated.
Last update: 2024-09-29 01:22:51 UTC
README
此模块提供了将任意值缓存到数据库的功能。
技术说明
在激活模块并定义contao设置中的最大缓存时间后,您可以使用以下代码(当然,如果已存在有效缓存结果,则会从缓存中检索)来获取特定请求的结果:
if (($strValue = DatabaseCache::getValue($strKey)) !== false)
{
$strResult = $strValue;
}
else
{
// do some logic in order to create $strResult
$strResult = someFunction();
DatabaseCache::cacheValue($strKey, $strResult);
}