Beispiel #1
0
 /**
  * Fetches a frozen object from the object storage and thaws it.
  *
  * @param string $id The ID of the object that is to be fetched.
  *
  * @return object
  */
 public function fetch($id)
 {
     // Bail out if a non-string was passed.
     if (!is_string($id)) {
         throw Object_Freezer_Util::getInvalidArgumentException(1, 'string');
     }
     // Try to retrieve object from the object cache.
     $object = $this->cache->get($id);
     if (!$object) {
         // Retrieve object from the object storage.
         $frozenObject = $this->doFetch($id);
         $this->fetchArray($frozenObject['objects'][$id]['state']);
         $object = $this->freezer->thaw($frozenObject);
         // Put object into the object cache.
         $this->cache->put($id, $object);
     }
     return $object;
 }
Beispiel #2
0
 /**
  * @covers  Object_Freezer_Cache::get
  */
 public function testGetReturnsFalseForNotExistingId()
 {
     $cache = new Object_Freezer_Cache();
     $this->assertFalse($cache->get('foo'));
 }