简介
在开发easyswoole组件时发现,MemcacheQ(微博自研消息队列)与memcache二进制协议不完全兼容,所以只能使用文本协议重新开发一个memcache协程客户端组件
安装
composer require huizhang/memcache
使用方式
<?php
include './vendor/autoload.php';
use Huizhang\Memcache\Memcache;
use Huizhang\Memcache\Config;
go(function () {
$config = new Config();
$config->setServers(
[
['0.0.0.0', 11211, 3],
['0.0.0.0', 11211, 3],
]
);
$client = new Memcache($config);
$client->set('test1', 123);
$client->set('test2', 123);
$client->add('test3', 123);
$client->replace('test1', 123);
$client->append('test1', 666, 3);
$client->cas('test1', 666, 1, 3);
$client->get('test1', 'test2', 'test3');
$client->gets('test1', 'test2', 'test3');
$client->delete('test1');
$client->incr('test1');
$client->decr('test1');
$client->stats();
$client->stats();
$client->statsSlabs();
$client->statsSizes();
$client->statsItems();
$client->flushAll();
});