示例#1
0
 /**
  * @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;
     }
 }
示例#2
0
 /**
  * @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');
 }
示例#3
0
 /**
  * @param $key
  * @return mixed|null
  */
 public function get($key)
 {
     return $this->cache->get($this->getKey($key));
 }