/** * @param $key * @param callable $cb * @return mixed|null */ public function get($key, callable $cb) { $item = $this->cache->get($key); if ($item === null) { $item = $cb(); $this->cache->set($key, $item); return $item; } else { return $item; } }
/** * @param $key * @return bool */ private function needsPregeneration($key) { $regenerateOn = $this->cache->get('sp' . $key); if ($regenerateOn === null) { return true; } if ($regenerateOn === 'locked') { return false; } $regenerateOn = DateTimeImmutable::createFromFormat(DateTime::ISO8601, $regenerateOn); return $regenerateOn <= new DateTimeImmutable('now'); }
/** * @param $key * @return mixed|null */ public function get($key) { return $this->cache->get($this->getKey($key)); }