2017 © Pedro Peláez
 

library silex-doctrine-cache-provider

Doctrine cache provider for Silex framework

image

sinsquare/silex-doctrine-cache-provider

Doctrine cache provider for Silex framework

  • Thursday, October 5, 2017
  • by SinSquare
  • Repository
  • 1 Watchers
  • 0 Stars
  • 897 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 34 % Grown

The README.md

Doctrine cache provider for Silex framework

Code quality Tests Issues
SensioLabsInsight Build Status Issue Count
Codacy Badge Test Coverage
Code Climate

Installation

With composer :, (*1)

``` json { "require": { "sinsquare/silex-doctrine-cache-provider": "1.*" } }, (*2)


Usage ===== You can use the provider with Pimple or Silex. First you have to create the condig for the cache, than you have to register the DoctrineCacheServiceProvider. ```php <?php use SinSquare\Cache\DoctrineCacheServiceProvider; $container = new Container(); $container['doctrine.cache.options'] = array( 'providers' => array( 'cache_name_1' => array( 'type' => 'void', ), ), ); $container->register(new DoctrineCacheServiceProvider());

To access a cache, you can either get if with the $container['doctrine.caches'][] or with $container['doctrine.cache.'], (*3)

<?php

$container['doctrine.cache.options'] = array(
    'providers' => array(
        'cache_name_1' => array(
            'type' => 'void',
        ),
    ),
);

$container->register(new DoctrineCacheServiceProvider());

$cache = $container['doctrine.caches']['cache_name_1'];
//OR
$cache = $container['doctrine.caches.cache_name_1'];

Options

Available cache types:, (*4)

APC, (*5)


$container['doctrine.cache.options'] = array( 'providers' => array( 'cache' => array( 'type' => 'apc' ), ), );

APCu, (*6)


$container['doctrine.cache.options'] = array( 'providers' => array( 'cache' => array( 'type' => 'apcu' ), ), );

Array, (*7)


$container['doctrine.cache.options'] = array( 'providers' => array( 'cache' => array( 'type' => 'array' ), ), );

Chain, (*8)


$container['doctrine.cache.options'] = array( 'providers' => array( 'cache' => array( 'type' => 'chain', 'caches' => array('cache_1', 'cache_2') ), 'cache_1' => array( 'type' => 'array' ), 'cache_2' => array( 'type' => 'apc' ), ), );

Filesystem, (*9)


$container['doctrine.cache.options'] = array( 'providers' => array( 'cache' => array( 'type' => 'filesystem', 'directory' => 'dir', 'extension' => 'value' //optional 'umask' => 'value' //optional ) ), );

Filesystem, (*10)


$container['doctrine.cache.options'] = array( 'providers' => array( 'cache' => array( 'type' => 'filesystem', 'directory' => 'dir', 'extension' => 'value' //optional 'umask' => 'value' //optional ) ), );

PHP file, (*11)


$container['doctrine.cache.options'] = array( 'providers' => array( 'cache' => array( 'type' => 'phpfile', 'directory' => 'dir', 'extension' => 'value' //optional 'umask' => 'value' //optional ) ), );

Memcache, (*12)


$container['doctrine.cache.options'] = array( 'providers' => array( 'cache' => array( 'type' => 'memcache', 'host' => 'host', 'port' => 'port' ) ), );

Memcached, (*13)


$container['doctrine.cache.options'] = array( 'providers' => array( 'cache' => array( 'type' => 'memcached', 'host' => 'host', 'port' => 'port' ) ), );

Void, (*14)


$container['doctrine.cache.options'] = array( 'providers' => array( 'cache' => array( 'type' => 'void' ) ), );

Creating custom cache

For creating a new cache provider all you have to do is the following: - create the new CacheType - define the $container['doctrine.cache.factory.'] - use the new provider in the config, (*15)

Creating the new Cache type, (*16)


<?php namespace Your\Name\Space; use Doctrine\Common\Cache\CacheProvider; class MyCustomCache extends CacheProvider { //class body with the required methods and functionality }

Create a factory for it, (*17)


//you have to define this BEFORE you get a new cache, preferably before registering the provider $container['doctrine.cache.factory.customcache'] = $container->protect(function ($cacheOptions) use ($container) { $namespace = $cacheOptions["namespace"]; // return new MyCustomCache(); });

Use it, (*18)


$container['doctrine.cache.options'] = array( 'providers' => array( 'cache' => array( 'type' => 'customcache' ) ), ); //getting the cache is the same as before

The Versions

05/10 2017

dev-master

9999999-dev

Doctrine cache provider for Silex framework

  Sources   Download

MIT

The Requires

 

The Development Requires

19/07 2017

v1.0.9

1.0.9.0

Doctrine cache provider for Silex framework

  Sources   Download

MIT

The Requires

 

The Development Requires

04/07 2017

v1.0.8

1.0.8.0

Doctrine cache provider for Silex framework

  Sources   Download

MIT

The Requires

 

The Development Requires

04/07 2017

v1.0.7

1.0.7.0

Doctrine cache provider for Silex framework

  Sources   Download

MIT

The Requires

 

The Development Requires

04/07 2017

v1.0.6

1.0.6.0

Doctrine cache provider for Silex framework

  Sources   Download

MIT

The Requires

 

The Development Requires

03/07 2017

v1.0.5

1.0.5.0

Doctrine cache provider for Silex framework

  Sources   Download

MIT

The Requires

 

15/02 2017

v1.0.4

1.0.4.0

Doctrine cache provider for Silex framework

  Sources   Download

MIT

The Requires

 

15/02 2017

v1.0.3

1.0.3.0

Doctrine cache provider for Silex framework

  Sources   Download

MIT

The Requires

 

15/02 2017

v1.0.2

1.0.2.0

Doctrine cache provider for Silex framework

  Sources   Download

MIT

The Requires

 

15/02 2017

v1.0.1

1.0.1.0

Doctrine cache provider for Silex framework

  Sources   Download

MIT

The Requires