Esempio n. 1
0
 /**
  * Resolves a dependency.
  *
  * If a cache is set, the cache is queried before calling <code>getResolve</code>.
  *
  * @param string $dependency the name of the dependency
  * @return mixed the resolved object
  */
 public function resolve($dependency)
 {
     if ($this->cache !== null) {
         $resolved = $this->cache->fetch($dependency);
         if ($resolved !== null) {
             return unserialize(base64_decode($resolved));
         }
     }
     $resolved = $this->getResolve($dependency);
     if ($this->cache !== null) {
         $this->cache->store($dependency, base64_encode(serialize($resolved)));
     }
     return $resolved;
 }
Esempio n. 2
0
 /**
  * Tests removing this cache.
  *
  * @covers empire\framework\storage\cache\Cache::remove
  */
 public function testRemove()
 {
     $this->cache->store('hello', 'world');
     $this->cache->store('hi', 'universe');
     $this->cache->store('hola', 'mars');
     $this->cache->store('priwjat', 'jupiter');
     $this->cache->remove();
     $this->assertSame(0, $this->cache->getNumberOfItems());
 }