Download the PHP package jonathan-neugber/cake-variable-cache without Composer
On this page you can find all versions of the php package jonathan-neugber/cake-variable-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jonathan-neugber/cake-variable-cache
More information about jonathan-neugber/cake-variable-cache
Files in jonathan-neugber/cake-variable-cache
Package cake-variable-cache
Short Description A simple config based variable cache plugin for CakePHP 3
License MIT
Informations about the package cake-variable-cache
CakePHP 3 cake-variable-cache
Description
This plugin is designed to asynchronously execute calculations that take a long amount of time and save the results (e.g.: Statistics).
It allows you to create a simple list of variables that are to be calculated every n-amount of time.
It also supports dependent variables (e.g.: variable bar
requires variable foo
to be calculated first).
Installation
1. require the plugin in your composer.json
"require": {
...
"jonathan-neugber/cake-variable-cache": "dev-master",
...
}
2. Include the plugin using composer
Open a terminal in your project-folder and run these commands:
$ composer update
$ composer install
3. Load the plugin in your config/bootstrap.php
Plugin::load('VariableCache', ['bootstrap' => true]);
4. Add configuration to your config/app.php
5. Migrations
Open a terminal in your project-folder and run this command:
$ bin/cake migrations migrate --source=../vendor/jonathan-neugber/cake-variable-cache/config/Migrations/
Usage / Example
1. Create a callback
Lets say you want to calculate a statistic:
2. Create a config
In the VariableCache.variables
section of the configuration add the following:
3. Import the config
Open a terminal in your project-folder and run this command:
$ bin/cake VariableCache.CachedVariables update
This will create the cached variables in the Database.
4. Run the queues
Execute the following commands in parallel in a terminal in your project-folder and run this command:
$ bin/cake VariableCache.CachedVariables
and
$ bin/cake queuesadilla
5. Access the variable
OR
OR
Additional Information
DynamicCalculationTrait
The DynamicCalculationTrait
allows you to easily create a library of callbacks for cached variables.
Using DynamicCalculationTrait::calculate()
as the callback will automatically call
the function calculate<CachedVariableName>
in the class.
Example:
Reset
This will reset all main cached variables so that a new execution is required.
$ bin/cake VariableCache.CachedVariables reset
TODO
- Write more tests
- Use mock class for CacheProviderInterface
- Test Cache Providers separately
- Update documentation
All versions of cake-variable-cache with dependencies
codekanzlei/cake-cktools Version 1.2.*
cakephp/cakephp Version ~3.4
josegonzalez/cakephp-queuesadilla Version *
php Version >=7.1