Storing an Item in the Cache


You want to store a value in the cache.


Use the Cache::put() method.

Cache::put($key, $value, $minutes);


Cache storage and retrieval usually follows the pattern below.

// 1. Pull the item from cache
$value = Cache::get($key);

// 2. Check if it was not found
if ($value === null)
    // 3. Figure the value manually
    $value = 'just something easy';

    // 4. Store it for a number of minutes
    $minutes = 30;
    Cache::put($key, $value, $minutes);
comments powered by Disqus