Storing an Item in the Cache Forever

Problem

You want to store an item in the cache indefintely.

Solution

Use the Cache::forever() method.

This will permanently store the item.

Cache::forever($key, $value);

Discussion

Clearing the cache will remove permanent items.

If you issue artisan cache:clear or call Cache::flush() then all items, including those stored with Cache::forever() will be removed.

comments powered by Disqus