2017 © Pedro PelĆ”ez
 

library cache-factory

Simple factory for php-cache/cache library (PSR-6 Cache implementation)

image

dgreda/cache-factory

Simple factory for php-cache/cache library (PSR-6 Cache implementation)

  • Friday, July 15, 2016
  • by dgreda
  • Repository
  • 1 Watchers
  • 0 Stars
  • 22 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Cache Factory

Author Software License Build Status codecov SensioLabsInsight, (*1)

Description

Simple Factory for php-cache/cache library (PSR-6 Cache implementation)., (*2)

Goal

To offer a simple way of creating different cache pool adapters based on simplified configurations., (*3)

Usage

The factory creates and returns a PSR-6 compatible cache pool based on small and tidy configuration provided as either PHP array or via YAML configuration file., (*4)

Installation

Library is available on Packagist, so you can simply run:, (*5)

composer require "dgreda/cache-factory":"v0.1.*"

Adapters

Currently factory supports the following adapters:, (*6)

  • Filesystem
  • Memcached
  • Predis

The goal is to implement all the adapters implemented by https://github.com/php-cache/cache, (*7)

Examples

There are some examples of usage under the "examples" directory., (*8)

Nevertheless, to give you a quick explanation and idea how it works, let's assume that you want to quickly obtain a Memcached cache pool implementation. You prepare the following YAML file and save it as 'cache.yml', (*9)

Cache:
  adapter:
    memcached:
      type: Memcached
      servers:
        memcached1: { host: localhost, port: 11211 }

Then in your PHP code you instantiate the factory and provide the config file to it, to easily make an instance of desired cache pool defined in the YAML:, (*10)

use Cache\Factory\Factory;

...

$cachePoolFactory = new Factory();

$cachePoolFactory->setConfigFile('cache.yml');

$cachePool = $cachePoolFactory->make('memcached');

Now you have the PSR-6 compatible instance of cache pool using the desired cache adapter!, (*11)

Your YAML file can contain several adapters defined and you can easily get a new instance of desired/needed cache pool by simply passing the name of the adapter as a parameter to the 'make' method of the factory., (*12)

Credits

Inspiration to create this library came from the flysystem-factory where I am also a contributor: https://github.com/Westwing-Home-and-Living/flysystem-factory, (*13)

The flysystem-factory library development was initiated by https://github.com/titosemi, (*14)

The Versions

15/07 2016

dev-tests

dev-tests

Simple factory for php-cache/cache library (PSR-6 Cache implementation)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damian Gręda

cache redis memcached factory psr-6

14/07 2016

dev-master

9999999-dev

Simple factory for php-cache/cache library (PSR-6 Cache implementation)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damian Gręda

cache redis memcached factory psr-6

14/07 2016

dev-insights

dev-insights

Simple factory for php-cache/cache library (PSR-6 Cache implementation)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damian Gręda

cache redis memcached factory psr-6

22/03 2016

v0.1.1

0.1.1.0

Simple factory for php-cache/cache library (PSR-6 Cache implementation)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damian Gręda

cache redis memcached factory psr-6

22/03 2016

v0.1.0

0.1.0.0

Simple factory for php-cache/cache library (PSR-6 Cache implementation)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damian Gręda

cache redis memcached factory psr-6