Cache¶
Simple request scope cache.
get¶
Returns object from cache. If there’s no object for the given key and $functions is passed, $function result will be stored in cache under the given key.
Parameters: $key
, $function = null
Example:
$countries = Cache::get("countries", function() {
//expensive computation that returns a list of countries
return Country::all();
})
memoize¶
Caches the result of the given closure using filename:line as a key.
Parameters: $function
Example:
$countries = Cache::memoize(function() {
//expensive computation that returns a list of countries
return Country::all();
})
size¶
Returns number of stored objects.
clear¶
Clear all items stored in cache.