isl / memcached-bundle
一个提供Memcached集成的Smyfony扩展包
dev-master
2016-11-03 06:43 UTC
Requires
- php: >=5.4
- symfony/symfony: ^2.7|^3.0
This package is not auto-updated.
Last update: 2024-09-23 13:09:59 UTC
README
此Symfony扩展包将Memcached集成到Symfony中,并以单例的形式提供配置的池。
该扩展包灵感来源于: https://gist.github.com/benr77/258e42642b4632d5a826 https://github.com/LeaseWeb/LswMemcacheBundle
要求
- php 5.4
- memcached 1.4或更高版本
- php-memcached 2.1或更高版本
安装
要使用Composer安装IslMemcachedBundle,只需将以下内容添加到您的'composer.json'文件中
{
require: {
"isl/memcached-bundle": "*",
...
}
}
接下来,您应该执行以下命令来安装扩展包
php composer.phar update isl/memcached-bundle
最后,将扩展包添加到'app/AppKernel.php'文件中AppKernel类的registerBundles函数中
public function registerBundles()
{
$bundles = array(
...
new Isl\MemcachedBundle\IslMemcachedBundle(),
...
);
安装以下依赖项(在基于Debian的系统上使用'apt')
apt-get install memcached php5-memcached
不要忘记在添加Memcache模块后重新启动您的web服务器。
配置
以下是可以用于此扩展包的示例配置。
isl_memcached: pools: default: servers: - { host: 10.0.0.1, port: 11211, weight: 15 } - { host: 10.0.0.2, port: 11211, weight: 30 } pool2: servers: - { host: 10.0.0.3, port: 11211, weight: 15 }
使用方法
$memcache = $this->get('isl.memcached')->getInstance('defaultpool', "persistentId optional");
$memcache->set('foo', 'bar'); $memcache->get('foo');
ADP: Anti Dog Pile
基于: https://github.com/LeaseWeb/LswMemcacheBundle
方法已修改,以与memcached扩展一起工作。
许可
此扩展包遵循MIT许可证。