66
77## Description
88
9- A multi-purpose cache engine in PHP with several drivers. PSR-6 compliant .
9+ A multi-purpose cache engine PSR-6 and PSR-16 implementation with several drivers.
1010
11- ## Avaible cache engines
11+ ## Cache Engine PSR-16 compliant
12+
13+ PSR-16 defines a Simple Cache interface with less verbosity than PSR-6. Below a list
14+ of engines available in this library that is PSR-16 compliant:
15+
16+ | Class | Description |
17+ | :----------------------------------------| :--------------------------------------------------------------------|
18+ | \ByJG\Cache\Psr16\NoCacheEngine | Do nothing. Use it for disable the cache without change your code |
19+ | \ByJG\Cache\Psr16\ArrayCacheEngine | Local cache only using array. It does not persists between requests |
20+ | \ByJG\Cache\Psr16\FileSystemCacheEngine | Save the cache result in the local file system |
21+ | \ByJG\Cache\Psr16\MemcachedEngine | Uses the Memcached as the cache engine |
22+ | \ByJG\Cache\Psr16\SessionCachedEngine | uses the PHP session as cache |
23+ | \ByJG\Cache\Psr16\ShmopCachedEngine | uses the shared memory area for cache |
24+
25+ To create a new Cache Instance just create the proper cache engine and use it:
1226
13- | Class | Description |
14- | :----------------------------------| :--------------------------------------------------------------------|
15- | \ByJG\Cache\NoCacheEngine | Do nothing. Use it for disable the cache without change your code |
16- | \ByJG\Cache\ArrayCacheEngine | Local cache only using array. It does not persists between requests |
17- | \ByJG\Cache\FileSystemCacheEngine | Save the cache result in the local file system |
18- | \ByJG\Cache\MemcachedEngine | Uses the Memcached as the cache engine |
19- | \ByJG\Cache\SessionCachedEngine | uses the PHP session as cache |
20- | \ByJG\Cache\ShmopCachedEngine | uses the shared memory area for cache |
27+ ``` php
28+ <?php
29+ $cache = new \ByJG\Cache\Psr16\FileSystemCacheEngine();
30+
31+ // And use it:
32+ $object = $cache->get('key');
33+ $cache->set('key', 'value');
34+ if ($cache->has('key')) {
35+ //...
36+ };
37+ ```
2138
22- ## Create new cache instance
39+ ## Cache Engine PSR-6 compliant
2340
24- ### Creating a PSR-6 compatible instance
41+ The PSR-6 implementation use the engines defined above. PSR-6 is more verbosity and
42+ have an extra layer do get and set the cache values.
2543
26- You can set instance in the 'cacheconfig.php' setup (see below how to configure the factory)
44+ You can use one of the factory methods to create a instance of the CachePool implementation:
2745
2846``` php
47+ <?php
2948$cachePool = \ByJG\Cache\Factory::createFilePool();
3049```
3150
32- or you can create the CachePool imediatelly :
51+ OR just create a new CachePool and pass to the constructor an instance of a PSR-16 compliant class :
3352
3453``` php
3554$cachePool = new CachePool(new FileSystemCacheEngine());
3655```
3756
38- ### Logging cache commands
39-
40- You can add a PSR Log compatible to the constructor in order to get Log of the operations
41-
42-
43- ### List of Avaiable Factory Commands
57+ ## List of Avaiable Factory Commands
4458
4559** Note: All parameters are optional**
4660
@@ -62,9 +76,13 @@ The Commom parameters are:
6276- servers: An array of memcached servers. E.g.: ` [ '127.0.0.1:11211' ] `
6377- config: Specific setup for shmop. E.g.: ` [ 'max-size' => 524288, 'default-permission' => '0700' ] `
6478
79+ ## Logging cache commands
80+
81+ You can add a PSR Log compatible to the constructor in order to get Log of the operations
82+
6583## Install
6684
67- Just type: ` composer require "byjg/cache-engine=3 .0.*" `
85+ Just type: ` composer require "byjg/cache-engine=4 .0.*" `
6886
6987
7088## Running Unit Testes
0 commit comments