soupmix / cache-memcached
0.3.3
2017-10-31 06:20 UTC
Requires
- php: >=5.6
- ext-memcached: *
- soupmix/cache-base: ~0.2
Requires (Dev)
- phpunit/phpcov: ^3.1.0
- phpunit/phpunit: ^5.4.0
- satooshi/php-coveralls: ~1.0
Provides
README
安装
建议您使用 Composer 安装 Soupmix Cache Memcached 适配器。
$ composer require soupmix/cache-memcached "~0.3"
连接
require_once '/path/to/composer/vendor/autoload.php'; $config = [ 'bucket' => 'test', 'hosts' => ['127.0.0.1'], ; $handler = new Memcached($config['bucket']); $handler->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true); $handler->setOption(Memcached::OPT_BINARY_PROTOCOL, true); if (!count($handler->getServerList())) { $hosts = []; foreach ($config['hosts'] as $host) { $hosts[] = [$host, 11211]; } $handler->addServers($hosts); } $cache = new Soupmix\Cache\MemcachedCache($handler);