marstato
marstato

Reputation: 365

Laravel + Wincache on MS Azure: Not storing values

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'));
}

The output is:

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.: As per phpinfo() the wincache usercache is enabled: wincache.ucenabled On


After some more debugging i know some more facts:

In an isolated php file wincache_ucache_set and wincache_ucache_get work perfectly.

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

Upvotes: 2

Views: 314

Answers (1)

Gary Liu
Gary Liu

Reputation: 13918

As there is a setting wincache.enablecli in php runtime to control whether wincache is enabled in CLI mode.

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

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

wincache.enablecli=1

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')); 
    }

or like:

use Cache;
public function fire()
    {

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

    }

Upvotes: 2

Related Questions