Download the PHP package epiphany/service-cache-bundle without Composer
On this page you can find all versions of the php package epiphany/service-cache-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package service-cache-bundle
Epiphany Service Cache Bundle
Allows caching of Symfony2 service method calls. This is achieved by annotating the required methods in the service class.
This functionality may be useful where:
- An application makes expensive calls to an API which could be cached or shared with another application, reducing overall API calls.
- An application makes time consuming calls to a service which could be cached for faster performance.
- As a means to hook into a method call for a service, then capture its parameters and return value.
Configuration
This assumes you're working with a Symfony2 (v2.3) application, and using composer for package management.
There are four steps required to use this bundle.
- Add this package to your composer.json file and run a composer update, add the package to you AppKernel
-
Update your application's app/autoload.php file to include a call to ProxyGenerator::registerNamespace(), as below, so the application can load proxy classes
-
Tag any services you want to register for caching, and tag a service which implements the Epiphany\ServiceCacheBundle\Cache\ServiceCacheInterface. This should be done in your service.yml/xml files
- Annotate any services you want to cache..
Annotations
@service-cache-enable
- This marks a method for use with the Service Cache
@service-cache-key <date|param> <value>
- One or more of these annotations must be used to define a unique key to store any data against. Any method parameter which can be cast as a string, or the current date (with a format string) can be used.
@service-cache-option <name> <value>
- Name/value pairs that will be passed to the caching service during get/set operations via an associative array. See the Epiphany\ServiceCacheBundle\Cache\ServiceCacheInterface. This allows a the user to pass extra information that might be specific to their implementation of the cache service such as compression, data expiry, (collection name if you're using MongoDB)
@service-cache-expires <n>
- Expiry in seconds of the cached data. Zero for never expires.
Implementing the Cache Mechanism
It is at the user's discretion as to what means of caching should be used. All that is required is that the user provides a Symfony2 service marked with the 'epiphany_service_cache.cache' tag, which implements the Epiphany\ServiceCacheBundle\Cache\ServiceCacheInterface. The getDataForKey() method should return a null value when no data can be retrieved from the cache.
Notes
This package expects the Symfony2 logger service to be available in the container (usually monolog, though any service implementing the Symfony\Component\HttpKernel\Log\LoggerInterface can be used).
To insert the caching layer, this package produces proxy objects for any marked service, and then overrides the service definition in Symfony's pre-optimization compiler pass of the service container. Currently, the proxy objects must be manually deleted from the application's app/cache/dsproxy directory whenever their service is updated.
Release Notes
v1.0.2 - September 23 2013
- Readme updates.
v1.0.1 - September 23 2013
- Readme updates.
v1.0.0 - September 23 2013
- Initial Commit, basic functionality.