1. Go to this page and download the library: Download sitegeist/stalemate library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sitegeist / stalemate example snippets
use \Sitegeist\StaleMate\Cache\ClosureCache as StaleMateCache;
/**
* @var VariableFrontend
*/
protected $cache;
/**
* @var StaleMateCache
*/
protected $staleMateCache;
/**
* @param VariableFrontend $cache
* @return void
*/
public function injectCache(VariableFrontend $cache): void
{
$this->cache = $cache;
}
public function initializeObject()
{
$staleMateCache = new \Sitegeist\StaleMate\Cache\ClosureCache(
$this->cache, // the variable frontend to cache the data in
8600, // lifetime for the items
4300, // gracePeriod where items are updated asynchronous
60 // lockPeriod for asynchronous updates
);
}
$result = $this->staleMateCache->resolve(
$cacheId, // identifier used to store the result, has to be unique
function () use ($stuffThatIsNeeded) {
$response = ... some expensive operation ...
return $response;
}, // closure to generate the result if no result is in the cache
['someTag'], // tags for the cache item
86400, // lifetime of the cached result until a refresh is needed
43200, // gracePeriod after lifetime where an update is performed async and the stale result is used
60 // lockPeriod for asynchronous updates
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.