Welcome to the Cookbook

loading...

8.7.1 Cache::read()

Es gibt zur Zeit keine Übersetzung für diesen Abschnitt. Bitte hilf mit und übersetze ihn. Mehr Informationen zu Übersetzungen

Cache::read($key, $config = null)

Cache::read() is used to read the cached value stored under $key from the $config. If $config is null the default config will be used. Cache::read() will return the cached value if it is a valid cache or false if the cache has expired or doesn't exist. The contents of the cache might evaluate false, so make sure you use the strict comparison operator === or !==.

For example:

$cloud = Cache::read('cloud');

if ($cloud !== false) {
	return $cloud;
}

// generate cloud data
// ...

// store data in cache
Cache::write('cloud', $cloud);
return $cloud;

  1. $cloud = Cache::read('cloud');
  2. if ($cloud !== false) {
  3. return $cloud;
  4. }
  5. // generate cloud data
  6. // ...
  7. // store data in cache
  8. Cache::write('cloud', $cloud);
  9. return $cloud;