I'm using Cache::remember
to Cache 3 results in my action, 2 in same call to Cache::remember
, it's work but I have 2 questions (below) about how I can join this Cache::remember
call.
I could use two
Cache::remember
in same method ?I coudl join this two
Cache::remember
(I need change the first param)?public function favoriteStores() { $userId = $this->Auth->user('id'); $username = $this->Auth->user('username');
list($fullBanners, $smallBanners,) = Cache::remember( 'banners', function(){ $this->loadModel('Banners'); $fullBanners = $this->Banners->full(); $smallBanners = $this->Banners->small(); return [$fullBanners, $smallBanners]; }); list($stores, $favoriteStores) = Cache::remember( 'stores', function(){ $stores = $this->Stores->myStores($this->Auth->user('id')); $favoriteStores = $this->Stores->favoriteStores(); return [$stores, $favoriteStores]; }); $this->set(compact('fullBanners', 'smallBanners', 'userId', 'username', 'stores', 'favoriteStores'));
}