Using Laravel 5.6 to cache queries using the memcached driver. When I use a variable in the key name, the results are never cached and it uses the database call but the same query works with 'test' as the key name. What am I missing?
Does not work...
/**
* Get one id
* @param $id
* @return \Illuminate\Database\Eloquent\Model|null|object|static
*/
public function get($id)
{
return Cache::rememberForever('species-' . $id, function () use ($id) {
return AnimalSpecies::where('id', $id)->with('subspecies', 'morphs', 'combos', 'localities')->first();
});
}
Does work...
/**
* Get one id
* @param $id
* @return \Illuminate\Database\Eloquent\Model|null|object|static
*/
public function get($id)
{
return Cache::rememberForever('test', function () use ($id) {
return AnimalSpecies::where('id', $id)->with('subspecies', 'morphs', 'combos', 'localities')->first();
});
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire