lundi 12 octobre 2015

how to cache count function in Laravel 5.1

I want to cache the count function of my acqusition model.

Indeed I have 1 800 000 acquis, and i dont want to count this every time.

I don't want to do it in each controllers I use like :

$count = ( ! Cache::has('count_acquisition')) ? Cache::put('count_acquisition', Acquisition::count(), 60) : Cache::get('count_acquisition');

It's quite heavy, I would prefer to do this directly in my Acquisition model, but I don't how.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire