06.10.2016 Views

laravel-5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Cache 280<br />

1 $value = Cache::pull('key');<br />

Storing Items In The Cache<br />

You may use the put method on the Cache facade to store items in the cache. When you place an<br />

item in the cache, you will need to specify the number of minutes for which the value should be<br />

cached:<br />

1 Cache::put('key', 'value', $minutes);<br />

Instead of passing the number of minutes until the item expires, you may also pass a PHP DateTime<br />

instance representing the expiration time of the cached item:<br />

1 $expiresAt = Carbon::now()->addMinutes(10);<br />

2<br />

3 Cache::put('key', 'value', $expiresAt);<br />

The add method will only add the item to the cache if it does not already exist in the cache store.<br />

The method will return true if the item is actually added to the cache. Otherwise, the method will<br />

return false:<br />

1 Cache::add('key', 'value', $minutes);<br />

The forever method may be used to store an item in the cache permanently. These values must be<br />

manually removed from the cache using the forget method:<br />

1 Cache::forever('key', 'value');<br />

Removing Items From The Cache<br />

You may remove items from the cache using the forget method on the Cache facade:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!