如何解决yii2 memcashe总是返回false
我想使用memcashe,以免每次都重新计算值。
'cache' => [
'class' => 'yii\caching\MemCache','useMemcached' => true,'servers' => [
[
'host' => '127.0.0.1','port' => 11211,],
然后尝试致电
$key = "installs" . $this->id;
$cache = \Yii::$app->cache;
$data = $cache->get($key);
if(!$data){
$cache->set($key,$data);
}
return $data;
但是$ data始终等于false。
我的nginx设置:
#memcashe
location ~ \ {
default_type text/html;
set $cachable 1;
if ($request_method != GET) {
proxy_pass http://127.0.0.1:80;
set $cachable 0;
break;
}
if ($http_cookie ~* "no_cache") {
proxy_pass http://127.0.0.1:80;
set $cachable 0;
break;
}
set $memcached_key "{$cookie_devicetype}_{$request_uri}";
memcached_pass 127.0.0.1:11211;
if ($cachable = 1) {
add_header X-Header-Memcached true;
}
error_page 404 = @proxy;
}
如何在yii2中正确使用memesache?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。