Microweber\Utils\Adapters\Cache\Storage\FileStorage::remember PHP Method

remember() public method

Get an item from the cache, or store the default value.
public remember ( string $key, DateTime | integer $minutes, Closure $callback ) : mixed
$key string
$minutes DateTime | integer
$callback Closure
return mixed
    public function remember($key, $minutes, Closure $callback)
    {
        $key = $this->appendLocale($key);
        // If the item exists in the cache we will just return this immediately
        // otherwise we will execute the given Closure and cache the result
        // of that execution for the given number of minutes in storage.
        if (!is_null($value = $this->get($key))) {
            return $value;
        }
        $this->put($key, $value = $callback(), $minutes);
        return $value;
    }

Usage Example

Beispiel #1
0
 /**
  * Get an item from the cache, or store the default value.
  *
  * @param  string        $key
  * @param  \DateTime|int $minutes
  * @param  Closure       $callback
  *
  * @return mixed
  */
 public function remember($key, $minutes, Closure $callback)
 {
     return $this->adapter->remember($key, $minutes, $callback);
 }