thefuriouscoder / doctrine-cache-factory
A simple static wrapper for Docrine Cache drivers.
Installs: 16 446
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 1
Requires
- php: >=5.3.3
- doctrine/cache: ~1.5.1
This package is not auto-updated.
Last update: 2025-04-26 21:18:52 UTC
README
A simple static wrapper for Doctrine Cache drivers.
Requirements
- PHP >= 5.3
- Doctrine Cache >= 1.5.1
Install
Composer
Add a dependency on thefuriouscoder/doctrine-cache-factory
to your project's composer.json
file.
{ "require": { "thefuriouscoder/doctrine-cache-factory": "dev-master" } }
Configuration
Initialize the Cache Store.
Add the following configuration code to your project bootstraping file depending on the storage you are goinng to use.
Using Memcached (php5-memcached extension needed)
// configure memcached setting. TFC\Cache\DoctrineCacheFactory::setOption( [ 'storage' => 'memcached', 'prefix' => 'rlyeh', 'default_ttl' => 3600, 'servers' => [ ['server1', 11211, 20], ['server2', 11211, 80] ] ] );
Using APC
// configure APC setting. TFC\Cache\DoctrineCacheFactory::setOption( [ 'storage' => 'apc', 'default_ttl' => 3600 ] );
Using Redis
// configure Redis setting. TFC\Cache\DoctrineCacheFactory::setOption( [ 'storage' => 'redis', 'prefix' => 'rlyeh', 'host => '127.0.0.1', 'port' => 6379, 'default_ttl' => 3600 ] );
Basic usage
$cache = \TFC\Cache\DoctrineCacheFactory::factory("redis"); $cache->setNamespace("miskatonic"); $cache->save($key,$data); $cache->contains($key); $data = $cache->fetch($key); $cache->delete($key); $cache->deleteAll();
For more detailed instructions on Doctrine cache usage, please refer to doctrine documentation
License
MIT License