kuikui/memcache-service-provider
最新稳定版本:v2.0.0
Composer 安装命令:
composer require kuikui/memcache-service-provider
包简介
Memcache integration for Silex.
关键字:
README 文档
README
It provides access to :
- a simple Memcache wrapper with very simple API for standard use,
- or your own Memcache wrapper with
$appinjection for custom use, - or a genuine Memcache(d) object for advanced use.
Installation
Create a composer.json in your projects root-directory :
{
"require": {
"kuikui/memcache-service-provider": "~2.0"
}
}
and run :
$ curl -sS http://getcomposer.org/installer | php
$ php composer.phar install
Registering
$app->register(new KuiKui\MemcacheServiceProvider\ServiceProvider());
Example
$app->register(new KuiKui\MemcacheServiceProvider\ServiceProvider()); // Simple use $app['memcache']->set('key', 'value'); $value = $app['memcache']->get('key'); $app['memcache']->delete('key'); // Advanced use : use \Closure to generate default value and save it during a retrieve process $value = $app['memcache']->get('key', function() use ($app) { return $app['some_other_service']->getData(); });
Options
After registration, you can customize the service with these options :
Connections
Allows you to set up one or more Memcache connections.
Each connection should be defined as follows array('ip_address', port).
$app['memcache.connections'] = array( array('127.0.0.1', 11211), array('10.0.1.118', 12345) ; // default: array('127.0.0.1', 11211)
Class
Allows you to choose between the two PHP Memcache libraries : \Memcache or \Memcached.
$app['memcache.class'] = '\Memcached'; // default: '\Memcache'
Wrapper
- By default, you access to an instance of
KuiKui\MemcacheServiceProvider\SimpleWrapper. - For custom needs, you can use your own wrapper :
$app['memcache.wrapper'] = '\My\Custom\Wrapper';
- Or you can have direct acces to Memcache(d) object :
$app['memcache.wrapper'] = false;
Duration
If you use SimpleWrapper, you can configure the default duration of cached data (in seconds):
$app['memcache.default_duration'] = 60; // default: 0 (no limit)
Running the tests
The development environment is provided by Vagrant and the Xotelia box.
$ cp Vagrantfile.dist Vagrantfile $ vagrant up $ vagrant ssh
$ cd /vagrant
$ composer install
$ ./vendor/bin/atoum
Dependencies
PHP 5.5+
MemcacheServiceProvider needs one of these PHP modules to be installed :
Credits
Deeply inspired by MemcacheServiceProvider from Rafał Filipek.
Tested with atoum.
License
The MemcacheServiceProvider is licensed under the MIT license.
统计信息
- 总下载量: 31.62k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-09-14