Cache::forever(key, value);
https://laravel.com/docs/5.4/cache#storing-items-in-the-cache
To update cache stored using forever(), you will have to forget() the key and readd it and the value again.
Hi,
I have some settings stored in the database and I want to cache them forever as they don't change often. When the user updates his settings, I delete the cache and add the new version to the cache.
How can I set this method to store the data forever?
´´´ $value = Cache::remember('users', $minutes, function () { return DB::table('users')->get(); }); ´´´
@eriktobben You’re looking for the rememberForever() method:
Cache::rememberForever('cache_key', function () {
// The result of the closure will be cached
// until you manually clear the cache key.
return $something;
});
Please or to participate in this conversation.