src/Psr16Manager.php
public function remember(string $key, \Closure $callback, $ttl = null)
    {
        $value = $this->get($key);
        // If the item exists in the cache we will just return this immediately and if
        // not we will execute the given Closure and cache the result of that for a
        // given number of seconds so it's available for all subsequent requests.
        if (!is_null($value)) {
            return $value;
        }

        $this->set($key, $value = $callback(), $ttl ?? $this->ttl);

        return $value;
    }
public function remember(string $key, \Closure $callback, $ttl = null)
    {
        $value = $this->get($key);
        // If the item exists in the cache we will just return this immediately and if
        // not we will execute the given Closure and cache the result of that for a
        // given number of seconds so it's available for all subsequent requests.
        if (!is_null($value)) {
            return $value;
        }

        $this->set($key, $value = $callback(), $ttl ?? $this->ttl);

        return $value;
    }
Get an item from the cache, or store the default value.

@param string                               $key      键
@param \Closure                             $callback 获取不到时的取值
@param \DateTimeInterface|\DateInterval|int $ttl      生命值

@return mixed