您的位置:首页 > 数据库 > Memcache

yii memcache 在 aliyun 开放缓存服务OCS运行方法

2015-09-23 17:52 555 查看
yii memcache 在阿里云上的解决方法,查看下面的链接

主要是aliyun ocs 需要配置 username 和 password ,这个与yii常规 CMemCache 不太一样

[php] view plaincopy在CODE上查看代码片派生到我的代码片

$connect = new Memcached;
$connect->setOption(Memcached::OPT_COMPRESSION, false);
$connect->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$connect->addServer('host', port);
$connect->setSaslAuthData('username', 'password');
$connect->set("hello", "world"); echo 'hello: ',$connect->get("hello");
$connect->quit();


我用以上代码,在服务器上能访问OCS

http://help.aliyun.com/view/11108324_13444498.html?spm=5176.7225337.1997284509.3.IEeHfl

https://github.com/aarondfrancis/yii-CMemCacheSASL

还有,上面的提示中有一点有误

'cache'=>array(
'class'=>'CMemCacheSASL',
'server'=> array(
'host'=>'host',
'port'=>11211,
'password'=>'xxxxxx',
'username'=>'xxxxxx'
),
),
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  yii aliyun php memcached