PHP code example of pahanini / yii2-neat-cache

1. Go to this page and download the library: Download pahanini/yii2-neat-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/ */

    

pahanini / yii2-neat-cache example snippets


$dependency = Yii::createObject([
	'class' => '\yii\caching\ChainedDependency',
	'dependOnAll' => false,
	'dependencies' => [
		Yii::createObject([
			'class' => '\yii\caching\ExpressionDependency',
			'expression' => 'Helper::isTimeToUpdate()',
		]),
		Yii::createObject([
			'class' => '\pahanini\neatcache\MutexDependency',
			'tag' => 'HeavyFunction',
		]),
	]
]);


	if (!$data = Yii::$app->cache->get('heavyDataId')) {
		Yii::$app->cache->set('heavyDataId', heavyFunctionCall(), 0, $dependency);		
	}
 php

'components' => [
	'mutex' => [
		'class' => 'tests\components\MysqlMutex',
	]
]
 php

return [
	'pageCache' => [
		'class' => '\pahanini\neatcache\PageCache',
		'only' => ['index'],
		'duration' => 0,
		'dependency' => [
			'class' => 'yii\caching\ExpressionDependency',
			'expression' => '\tests\NeatCacheTest::$tag',
		],
	],
];