Laravel - Cache - Retrieving Items From The Cache

The Cache facade's get method is used to retrieve items from the cache. If the item does not exist in the cache, null will be returned. If you wish, you may pass a second argument to the get method specifying the default value you wish to be returned if the item doesn't exist:

    
    $value = Cache::get('key');
    
    $value = Cache::get('key', 'default');
	

You may even pass a closure as the default value. The result of the closure will be returned if the specified item does not exist in the cache. Passing a closure allows you to defer the retrieval of default values from a database or other external service:

    
    $value = Cache::get('key', function () {
        return DB::table(...)->get();
    });