straightsoft / contao-database_cache
This module offers functionality for caching request results to database.
Installs: 25
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:contao-module
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-11-10 01:49:53 UTC
README
This module offers functionality for caching arbitrary values to database.
Technical instructions
After activating the module and defining the maximum cache time in the contao settings, you can retrieve the result for a certain request by using the following code (of course, retrieved from cache if there's already a cached result which isn't outdated):
if (($strValue = DatabaseCache::getValue($strKey)) !== false)
{
$strResult = $strValue;
}
else
{
// do some logic in order to create $strResult
$strResult = someFunction();
DatabaseCache::cacheValue($strKey, $strResult);
}