2017 © Pedro Peláez
 

zf2-module cachedecorator

Simple cache decorator module for zf2 projects

image

sedpro/cachedecorator

Simple cache decorator module for zf2 projects

  • Friday, December 11, 2015
  • by sedpro
  • Repository
  • 1 Watchers
  • 1 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

CacheDecorator

Version 0.1, (*1)

This module allows you simple caching of your service methods., (*2)

The main idea was to create a caching module, which can be connected to a project without changing code. All you need to do is ajust your config., (*3)

Installation

For the installation uses composer composer., (*4)

php composer.phar require  sedpro/cachedecorator:dev-master

Add this project in your composer.json:, (*5)

"require": { "sedpro/cachedecorator": "dev-master" }, (*6)

Post Installation

Configuration: - Add the module of config/application.config.php under the array modules, insert Cachedecorator - Remove services, you want to cache, from getServiceConfig function in file Module.php - In your config/autoload/global.php file add two values:, (*7)

php 'caches' => [ \Cachedecorator\Module::STORAGE => [ 'adapter' => [ 'name' => 'memcached', ], 'options' => [ 'ttl' => 3600, 'servers' => [ 'node0' => [ 'host' => '127.0.0.1', 'port' => 11211, ], ], 'namespace' => 'some_ns:', ], ], ], \Cachedecorator\Module::METHODS => [ 'Application\Service\Example' => [ 'getItems', ], ],, (*8)

'caches' contains all caches you use in project. They will be instantiate in abstact factory Zend\Cache\Service\StorageCacheAbstractServiceFactory which is called in vendor/sedpro/cachedecorator/config/module.config.php. If you are already using this factory, there will be no conflict., (*9)

'\Cachedecorator\Module::STORAGE' is cache storage adapter, used to store the output of your services., (*10)

'\Cachedecorator\Module::METHODS' is list of services you want to cache. Cached will be only listed functions., (*11)

Example

If you use the configuration, showed above, method getItems of class Application\Service\Example will be cached. You can use it as usual:, (*12)

php $exampleService = $this->getServiceLocator()->get('Application\Service\Example'); $items = $exampleService->getItems(); // cached $values = $exampleService->getValues(); // not cached, (*13)

The Versions

11/12 2015

dev-master

9999999-dev https://github.com/sedpro/cachedecorator

Simple cache decorator module for zf2 projects

  Sources   Download

BSD-3-Clause

The Requires

 

by Prokhor sednev

cache zf2 module cache decorator