Laravel Classroom image

Prashant  Nigam / Student / Web Technology

To post your Question Join Classroom
Lesson Topics's No:-  First|1 | 2 | 3 | 4|Last

17.2 Setting values
You can use the put() or forever() methods to store data in the Cache.
The put() method allows you to store a value for a set period of time, let’s have a look at a code
1 <?php
3 $data = 'complicated_generated_data';
4 Cache::put('mydata', $data, 10);
Let’s pretend that $data wasn’t just an assigned string, but the result of a complicated algorithm
that would take some time to process. We don’t want to process this data all the time, so we
keep it in the cache.
The first parameter to the method is the key, a string used to identify the cached data. The second
parameter is the data itself, and the third is the amount of time in minutes to cache to the data.
The forever() method takes only the first two parameters, and acts exactly as the name implies.
The data is cached forever.


Prashant  Nigam

Skills    Laravel

Qualifications :-
Location :-,,,

  Students (0)