11# Cache Engine
2+ [ ![ Scrutinizer Code Quality] ( https://scrutinizer-ci.com/g/byjg/cache-engine-php/badges/quality-score.png?b=master )] ( https://scrutinizer-ci.com/g/byjg/cache-engine-php/?branch=master )
23[ ![ SensioLabsInsight] ( https://insight.sensiolabs.com/projects/f643fd22-8ab1-4f41-9bef-f9f9e127ec0d/mini.png )] ( https://insight.sensiolabs.com/projects/f643fd22-8ab1-4f41-9bef-f9f9e127ec0d )
4+ [ ![ Build Status] ( https://travis-ci.org/byjg/cache-engine-php.svg?branch=master )] ( https://travis-ci.org/byjg/cache-engine-php )
5+
36
47## Description
58
@@ -18,12 +21,12 @@ A multi-purpose cache engine in PHP with several drivers. PSR-6 compliant.
1821
1922## Create new cache instance
2023
21- ### Creating a PSR-6 compatible instance (RECOMMENDED)
24+ ### Creating a PSR-6 compatible instance
2225
2326You can set instance in the 'cacheconfig.php' setup (see below how to configure the factory)
2427
2528``` php
26- $cachePool = \ByJG\Cache\CacheContext::psrFactory ();
29+ $cachePool = \ByJG\Cache\Factory::createFilePool ();
2730```
2831
2932or you can create the CachePool imediatelly:
@@ -32,101 +35,45 @@ or you can create the CachePool imediatelly:
3235$cachePool = new CachePool(new FileSystemCacheEngine());
3336```
3437
38+ ### Logging cache commands
39+
40+ You can add a PSR Log compatible to the constructor in order to get Log of the operations
3541
36- ### Use the cache engine instance
3742
38- You can create a instance from the Cache engine directly. This is not PSR-6 compliant, but implements
39- features that the CachePool does not support and it is for backward compatibilty also.
43+ ### List of Avaiable Factory Commands
4044
41- You can create from the factory and cacheconfig.php file:
45+ ** Note: All parameters are optional **
4246
43- ``` php
44- $cacheEngine = \ByJG\Cache\CacheContext::factory();
45- ```
47+ | Engine | Factory Command |
48+ | :-----------------| :----------------------------------------------------------------------|
49+ | No Cache | Factory::createNullPool($prefix, $bufferSize, $logger); |
50+ | Array | Factory::createArrayPool($bufferSize, $logger); |
51+ | File System | Factory::createFilePool($prefix, $bufferSize, $logger); |
52+ | Memcached | Factory::createMemcachedPool($servers[ ] , $bufferSize, $logger); |
53+ | Session | Factory::createSessionPool($prefix, $bufferSize, $logger); |
54+ | Redis | Factory::createRedisCacheEngine($server, $pwd, $bufferSize, $logger); |
55+ | Shmop | Factory::createShmopPool($config[ ] , $bufferSize, $logger); |
4656
47- or instantiate directly
57+ The Commom parameters are:
4858
49- ``` php
50- $cacheEngine = new \ByJG\Cache\MemcachedEngine();
51- ```
59+ - logger: A valid instance that implement the LoggerInterface defined by the PSR/LOG
60+ - bufferSize: the Buffer of CachePool
61+ - prefix: A prefix name to compose the KEY physically
62+ - servers: An array of memcached servers. E.g.: ` [ '127.0.0.1:11211' ] `
63+ - config: Specific setup for shmop. E.g.: ` [ 'max-size' => 524288, 'default-permission' => '0700' ] `
5264
5365## Install
5466
55- Just type: ` composer require "byjg/cache-engine=2.0.*" `
56-
57- ## Setup the Factory Config
58-
59- You need to have a file named ` config/cacheconfig.php ` with the follow contents:
60-
61- ### Basic Configuration
62-
63- ``` php
64- return [
65- 'default' => [
66- 'instance' => '\\ByJG\\Cache\\NoCacheEngine'
67- ]
68- ];
69- ```
70-
71- The parameters are described below:
72-
73- * 'default' is the name of the key used in the CacheContext::factory(key)
74- * 'instance' is required if you use CacheContext::factory. Must have the full name space for the cache class;
75-
76- ### Setting the Cache Pool Buffer
67+ Just type: ` composer require "byjg/cache-engine=3.0.*" `
7768
78- CachePool implementation have a local buffer saving some elements locally for speedup the access.
79- If you set to '0' the pool buffer will be disabled.
8069
81- ``` php
82- return [
83- 'default' => [
84- 'instance' => '\\ByJG\\Cache\\MemcachedEngine',
85- 'poolbuffer' => 10
86- ]
87- ];
88- ```
89-
90-
91- ### Specific configuration for Memcached
70+ ## Running Unit Testes
9271
93- ``` php
94- return [
95- 'default' => [
96- 'instance' => '\\ByJG\\Cache\\MemcachedEngine',
97- 'memcached' => [
98- 'servers' => [
99- '127.0.0.1:11211'
100- ]
101- ],
102- ]
103- ];
10472```
105-
106- The parameters are described below:
107-
108- * 'memcached' have specific configuration for the MemcachedEngine class.
109-
110- ### Specific configuration for Shmop Cache
111-
112- ``` php
113- return [
114- 'default' => [
115- 'instance' => '\\ByJG\\Cache\\ShmopCacheEngine',
116- 'shmop' => [
117- 'max-size' => 1048576,
118- 'default-permission' => '0700'
119- ]
120- ]
121- ];
73+ phpunit --stderr
12274```
12375
124- The parameters are described below:
125-
126- * 'shmop' have specific configuration for the ShmopCacheEngine class.
127-
128-
129-
76+ ** Note:** the parameter ` --stderr ` after ` phpunit ` is to permit run the tests on SessionCacheEngine.
13077
13178----
13279[ Open source ByJG] ( http://opensource.byjg.com )
0 commit comments