Organizing Your Cache into Sections


You have many items in your cache and want to organize them.


Organize your cache into sections.

You can use the Cache::section() method to specify categories or groups of cache keys.

$item = Cache::section('inventory')->get('last-purchased');

The nice thing about sections is you can treat the entire section as sort of a "mini-cache" and use all the cache methods on just that section.

// Store a value
Cache::section('section')->put('key', 'value', $minutes);

// Retrieve a value
$value = Cache::section('section')->get('key');

// Flush the whole section


Sections aren't available for every Cache driver.

Neither the File Cache driver nor the Database Cache driver supports cache sections.

comments powered by Disqus