MS Azure上的Laravel + Wincache:不存储值 [英] Laravel + Wincache on MS Azure: Not storing values

查看:35
本文介绍了MS Azure上的Laravel + Wincache:不存储值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在azure上运行一个PHP应用程序,并且遇到了一些奇怪的现象:在控制台命令中运行了以下代码片段:

I am running a PHP application on azure and am experiencing some strange behaviour: This snippet runns in a Console command:

public function fire(Illuminate\Contracts\Cache\Repository $cache) {
    $cache->forever('someKey', 'someValue');

    var_dump($cache->get('someKey'));
}

输出为:

NULL

在执行命令后通过wincache_ucache_get访问该值也将返回NULL(带前缀和不带前缀).有任何线索吗?

Accessing the value through wincache_ucache_get after executing the command also returns NULL (with prefix and without). Has anyone a clue on this?

P.S .:根据phpinfo(),启用了wincache用户缓存:wincache.ucenabled开

P.S.: As per phpinfo() the wincache usercache is enabled: wincache.ucenabled On

经过更多调试后,我知道了更多事实:

After some more debugging i know some more facts:

在一个独立的php文件中, wincache_ucache_set wincache_ucache_get 完美地工作.

In an isolated php file wincache_ucache_set and wincache_ucache_get work perfectly.

但是,对 Illuminate \ Cache \ WinCacheStore 中的 wincache_ucache_set 的调用返回 false .

However, the call to wincache_ucache_set in Illuminate\Cache\WinCacheStore returns false.

推荐答案

由于存在设置默认情况下将其设置为0,以使函数 wincache_ucache_set()在工匠命令中不起作用.

By default it is set 0 so that the function wincache_ucache_set() cannot work in artisan commands.

您可以参考Azure官方上有关

You can refer to the guide on Azure official about Changing PHP_INI_SYSTEM configuration settings, to set the

wincache.enablecli = 1

在其他php配置设置中.

in additional php configuration settings.

然后以下代码段应该可以正常工作:

Then the following code snippet should work well:

public function fire()
    {
        wincache_ucache_set('foo','goo',0);
        var_dump(wincache_ucache_get('foo')); 
    }

或类似的

use Cache;
public function fire()
    {

        Cache::forever('someKey', 'someValue');
        var_dump(Cache::get('someKey'));

    }

这篇关于MS Azure上的Laravel + Wincache:不存储值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆