straightsoft/contao-database_cache

This module offers functionality for caching request results to database.

Maintainers

Package info

github.com/straightsoft/contao-database_cache

Type:contao-module

pkg:composer/straightsoft/contao-database_cache

Statistics

Installs: 28

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.6 2017-12-01 15:29 UTC

This package is not auto-updated.

Last update: 2026-03-01 08:44:02 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);
}