Raheel Hasan
Raheel Hasan

Reputation: 6013

Laravel5 - Cache::remember forever

Im trying to implement laravel's cache using the remember method. So how do I implement a forever with this? I tried passing 0 or null as minutes but it doesnt work.

I want the cache to be stored until its revoked my the code (i.e. forever).

Thanks

Upvotes: 2

Views: 1526

Answers (2)

Raheel Hasan
Raheel Hasan

Reputation: 6013

The answer I found myself is to use rememberForever. Like this:

$my_data = Cache::rememberForever('key_123', function(){
//fetch from db and add to cache if not found
}

Upvotes: 1

ShaneDaugherty
ShaneDaugherty

Reputation: 427

Just call Cache::forever('key','value')

Upvotes: 0

Related Questions