save() public method

public save ( Psr\Cache\CacheItemInterface $item )
$item Psr\Cache\CacheItemInterface
Ejemplo n.º 1
0
 /**
  * @return AircraftCollection
  */
 public function getAllAircraft()
 {
     if ($this->cacheEnabled) {
         $cacheItem = $this->cachePool->getItem('aircraftCollection');
         $aircraftCollection = $cacheItem->get();
         if ($cacheItem->isHit()) {
             return $aircraftCollection;
         }
     }
     $fileObjects = $this->recursiveIterator;
     $aircraftCollection = $this->aircraftCollection;
     foreach ($fileObjects as $file) {
         if ($file->getFilename() === 'aircraft.json') {
             $json = file_get_contents($file->getPathName());
             if ($json) {
                 $aircraftConfig = json_decode($json);
                 $aircraftConfig->path = $file->getPath();
                 $aircraftCollection->push($aircraftConfig);
             }
         }
     }
     if ($this->cacheEnabled) {
         $this->cachePool->save($cacheItem->set($aircraftCollection));
     }
     return $aircraftCollection;
 }
Ejemplo n.º 2
0
 /** @inheritDoc */
 public function get($key, callable $callback)
 {
     assert(is_string($key) || is_int($key));
     $item = $this->stash->getItem((string) $key);
     $result = $item->get();
     if ($item->isMiss()) {
         $item->lock();
         $result = call_user_func($callback);
         $this->stash->save($item->set($result));
     }
     return $result;
 }
Ejemplo n.º 3
0
 public function testConstruction()
 {
     $key = array('apple', 'sauce');
     $driver = new Sqlite(array());
     $pool = new Pool();
     $pool->setDriver($driver);
     $item = $pool->getItem('testKey');
     $item->set($key);
     $this->assertTrue($pool->save($item), 'Able to load and store with unconfigured extension.');
 }
Ejemplo n.º 4
0
 public function save(CacheItemInterface $item)
 {
     $this->pool->save($item);
 }