jeudi 24 mai 2018

Laravel & memcached

I have some interesting problem, that i cant solve alone.

On laravel 5.2 in AppServiceProvider i have

   $regionList = Cache::store('memcached')->get('regionList'); 

   if (empty($regionList)){
        $regions = new \App\Models\RegionalConfig();
        $regionList = $regions->getVersionsList()->toArray();
        Cache::store('memcached')->put('regionList', $regionList, 36000);
   }  

and this perfectly works.

But if i put this part in any controller, my $regionList will be always empty. So, there is no insert in memcache.

Why this happend?

My config cache file:

'default' => env('CACHE_DRIVER', 'memcached'),
...
'memcached' => [
            'driver'  => 'memcached',
            'servers' => [
                [
                    'host' => env('MEMCACHED_HOST', '127.0.0.1'),
                    'port' => env('MEMCACHED_PORT', 11211),
                    'weight' => 1000,
                ],
            ],
        ],

Thank you!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire