pcelta/doctrine-cache-factory
最新稳定版本:0.1.0
Composer 安装命令:
composer require pcelta/doctrine-cache-factory
包简介
A Doctrine Cache Factory
关键字:
README 文档
README
doctrine-cache-factory
Doctrine Cache Factory it's better way to uncouple your application of the cache adapters. Changing just the configuration the factory will load a different client.
Instalation
{
"require": {
"pcelta/doctrine-cache-factory": "dev-master"
}
}
Adapters Availables
- Custom
- Array
- Memcache
- Memcached
- Redis
Write your own adapter
Use the adapter namespace to specify the location of your adapter.
use Pcelta\Doctrine\Cache\Factory; $factory = new Factory(); $cacheSettings [ 'adapter' => 'Memcache', 'adapter_namespace' => '\Doctrine\Common\Cache\%sCache', 'host' => '127.0.0.1', 'port' => 11211, ]; $cacheProvider = $factory->create($cacheSettings);
How to use Array
use Pcelta\Doctrine\Cache\Factory; $factory = new Factory(); $cacheSettings [ 'adapter' => 'Array', ]; $cacheProvider = $factory->create($cacheSettings);
How to use Memcache
Install php5-memcache
sudo apt-get install php5-memcache
use Pcelta\Doctrine\Cache\Factory; $factory = new Factory(); $cacheSettings [ 'adapter_name' => 'Memcache', 'host' => '127.0.0.1', 'port' => 11211, ]; $cacheProvider = $factory->create($cacheSettings);
How to use Memcached
Install php5-memcached
sudo apt-get install php5-memcached
use Pcelta\Doctrine\Cache\Factory; $factory = new Factory(); $cacheSettings [ 'adapter_name' => 'Memcached', 'host' => '127.0.0.1', 'port' => 11211, ]; $cacheProvider = $factory->create($cacheSettings);
How to use Redis
install PHPRedis
git clone git@github.com:phpredis/phpredis.git
cd phpredis
phpize
./configure
make && make install
use Pcelta\Doctrine\Cache\Factory; $factory = new Factory(); $cacheSettings [ 'adapter_name' => 'Redis', 'host' => '127.0.0.1', 'port' => 11211, ]; $cacheProvider = $factory->create($cacheSettings);
General Usage
use Pcelta\Doctrine\Cache\Factory; $factory = new Factory(); $cacheSettings [ 'adapter_name' => 'Memcache', 'host' => '127.0.0.1', 'port' => 11211, ]; $cacheProvider = $factory->create($cacheSettings); $cacheProvider->save('your-key', 'your-data'); $data = $cacheProvider->fetch('your-key'); echo $data; // your-data
Comparing Doctrine Cache Factory with Doctrine Cache Pure
Doctrine Cache
$memcache = new Memcache(); // it's bad to uncouple $memcache->connect('memcache_host', 11211); $cacheDriver = new \Doctrine\Common\Cache\MemcacheCache(); $cacheDriver->setMemcache($memcache); $cacheDriver->save('cache_id', 'my_data');
Doctrine Cache Factory
$factory = new \Pcelta\Doctrine\Cache\Factory(); $cacheSettings [ 'adapter_name' => 'Memcache', // it's much better 'host' => '127.0.0.1', 'port' => 11211, ]; $cacheProvider = $factory->create($cacheSettings); $cacheProvider->save('cache_id', 'your-data');
Road Map
- Couchbase
License
MIT License
统计信息
- 总下载量: 18.23k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-05-26