soupmix/cache-memcached

此包已被 废弃 且不再维护。作者建议使用 soupmix/cache 包代替。

独立于框架的 Memcached 适配器,适用于 SimpleCache 接口。

0.3.3 2017-10-31 06:20 UTC

This package is auto-updated.

Last update: 2021-06-26 21:46:00 UTC


README

Build Status Scrutinizer Code Quality Codacy Badge Code Climate Latest Stable Version Total Downloads Latest Unstable Version License composer.lock Code Coverage

安装

建议您使用 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);

Soupmix Memcached 缓存 API

请参阅 Soupmix 缓存 API