mactronique / phpcache
This package is abandoned and no longer maintained.
The author suggests using the psr/simple-cache package instead.
Avanced cache manager for PHP. Driver : xcache and wincache
1.0.5
2016-11-09 20:05 UTC
Requires
- php: >=5.4
Requires (Dev)
- atoum/atoum: master-dev
Suggests
- ext-redis: For use Redis Driver
- ext-xcache: For use xCache Driver
- predis/predis: For use Predis driver
README
Supported driver
- xCache
- WinCache
- Predis
- Redis
- Memcached
- Null (special for instanciate no effect cache driver)
Install
php composer.phar require mactronique/phpcache "~1.0"
Configuration
for xCache
No configuration need.
for WinCache
No configuration need.
for Null
No configuration need.
For Predis
$config = array( "host" => "127.0.0.1", "port" => "", "password" => "", "database" => "", "timeout" => 1, "read_write_timeout" => 1 );
Only host
key is required.
For Redis
$config = array( "host" => "127.0.0.1", "port" => "", "password" => "", "database" => "", "timeout" => 1 );
Only host
key is required.
For Redis
$config = array( "host" => "127.0.0.1", "port" => 11211, "sharing" => 100 );
Only host
key is required.
Example of use NullDriver
This code is example of service class
use Mactronique\PhpCache\Service\PhpCache; use Mactronique\PhpCache\Driver\NullDriver; class myService { private $cache public function __construct(PhpCache $cache = null) { if (null === $cache) { $cache = new PhpCache(); $cache->registerDriver(new NullDriver()); } $this->cache = $cache; } public function myAction() { /* You can use the cache but never key exist and all get return null. */ $val = $this->cache->get('key'); [...] } }