1. Go to this page and download the library: Download stroker/cache 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/ */
public function onBootstrap(MvcEvent $e)
{
$serviceManager = $e->getApplication()->getServiceManager();
$cacheService = $serviceManager->get('strokercache_service');
$cacheService->getEventManager()->attach(CacheEvent::EVENT_SAVE, function (CacheEvent $e) {
$e->setTags(['custom_tag']);
});
}
public function onBootstrap(MvcEvent $e)
{
$serviceManager = $e->getApplication()->getServiceManager();
$logger = new \Laminas\Log\Logger();
$logger->addWriter(new \Laminas\Log\Writer\Stream('/log/strokercache.log'));
$cacheService = $serviceManager->get('strokercache_service');
$cacheService->getEventManager()->attach(CacheEvent::EVENT_SAVE, function (CacheEvent $e) use ($logger) {
$logger->debug('Saving page to cache with ID: ' . $e->getCacheKey());
});
}
public function onBootstrap(MvcEvent $e)
{
$serviceManager = $e->getApplication()->getServiceManager();
$cacheService = $serviceManager->get('strokercache_service');
$cacheService->getEventManager()->attach(CacheEvent::EVENT_SHOULDCACHE, function (CacheEvent $e) {
if ($e->getMvcEvent()->getRequest()->getUri()->getPort() == 8080) {
$e->stopPropagation(true);
return false;
}
return true;
}, 1000);
}
public function onBootstrap(MvcEvent $e)
{
$serviceManager = $e->getApplication()->getServiceManager();
$cacheService = $serviceManager->get('strokercache_service');
$cacheService->getEventManager()->attach(CacheEvent::EVENT_LOAD, function (CacheEvent $e) {
$loggedIn = /* your logic here */;
if ($loggedIn) {
$e->stopPropagation(true);
return false;
}
}, 1000);
}
public function onBootstrap(MvcEvent $e)
{
$serviceManager = $e->getApplication()->getServiceManager();
$cacheService = $serviceManager->get('strokercache_service');
$cacheService->getEventManager()->attach(CacheEvent::EVENT_SHOULDCACHE, function (CacheEvent $e) {
$loggedIn = /* your logic here */;
if ($loggedIn) {
$e->stopPropagation(true);
return false;
}
}, 1000);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.