Download the PHP package webiny/cache without Composer
On this page you can find all versions of the php package webiny/cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cache
Cache Component
Cache
component give you ability to store different information into memory for a limited time.
Install the component
The best way to install the component is using Composer.
For additional versions of the package, visit the Packagist page.
Supported drivers
The cache component supports following cache drivers:
APC
(http://php.net/manual/en/book.apc.php)- only available in PHP 5.4, from PHP 5.5 APC is not supported
Couchbase
(http://www.couchbase.com/develop/php/current)Memcache
(http://php.net/manual/en/book.memcache.php)Redis
(http://redis.io/clients)
If you are not sure which driver to use, we suggest Memcache
.
Based on the selected driver, you'll have to pass different options to the constructor.
Requirements
The default bridged library is Memory
by Jamm
(https://github.com/jamm/Memory).
It is required that you add this library to the ClassLoader
:
For example:
Common operations
Once you have created your Cache
instance, you can start using your cache.
The cache methods are the same, no matter which driver you use:
Cache config
The preferred way of defining cache drivers is creating them inside your the config file of your application.
See the ExampleConfig.yaml
for additional details.
Under Cache
you define the cache drivers by giving each of them a cache id
and underneath you nest its config.
The driver configuration depends on which driver you are using.
If you wish to turn off the cache, use the BlackHole
driver.
The Method
parameter must be a valid callback function that will return an instance of CacheStorage
.
The benefit of defining cache drivers in this way is that the drivers are initialized the second Webiny Framework is loaded. This enables you to access the cache by 'CacheTrait'.
Custom Cache
driver
To implement you own custom cache driver you must first create a class that will implement \Webiny\Component\Cache\Bridge\CacheInterface
.
Once you have that class, create another class with a static function that will return an instance of CacheDriver
.
Now just set your class and the static method as the Method
inside your config and you can access the cache
over the CacheTrait
.
Resources
To run unit tests, you need to use the following command:
$ cd path/to/Webiny/Component/Cache/
$ composer.phar install
$ phpunit
Make sure that you also set your cache driver details in Tests/ExampleConfig.yaml
.
All versions of cache with dependencies
webiny/std-lib Version ~1.6
webiny/config Version ~1.6
webiny/service-manager Version ~1.6
webiny/forked-jamm-memory Version ~1.0