Ejemplo n.º 1
0
 public function testGetExpire()
 {
     $time = time() + 3600;
     $expire = new \DateTime();
     $this->item->expiresAt($expire->setTimestamp($time));
     $this->assertEquals($time, $this->item->getExpiration()->getTimestamp());
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function getItems(array $keys = array())
 {
     if ($this->deferred) {
         $this->commit();
     }
     $dataKeys = [];
     foreach ($keys as $key) {
         $dataKeys[] = $this->createKey($key);
     }
     $values = $this->getArrayDataFromStorage($dataKeys);
     $items = [];
     foreach ($keys as $key) {
         $item = new CacheItem($key, $this->ttl);
         $storageKey = $this->createKey($key);
         if (isset($values[$storageKey])) {
             $item->setHit(true);
             $item->set($values[$storageKey]);
         } else {
             $item->setHit(false);
         }
         $items[$key] = $item;
     }
     return $items;
 }