Esempio n. 1
0
 /**
  * tests the value access methods
  */
 public function testValueAccess()
 {
     $memoryManager = new DummyMemoryManager();
     $memObject = new Container\Movable($memoryManager, 10, '0123456789');
     // getRef() method
     $this->assertEquals($memObject->getRef(), '0123456789');
     $valueRef =& $memObject->getRef();
     $valueRef[3] = '_';
     $this->assertEquals($memObject->getRef(), '012_456789');
     // value property
     $this->assertEquals((string) $memObject->value, '012_456789');
     $memObject->value[7] = '_';
     $this->assertEquals((string) $memObject->value, '012_456_89');
     $memObject->value = 'another value';
     $this->assertTrue($memObject->value instanceof \Zend\Memory\Value);
     $this->assertEquals((string) $memObject->value, 'another value');
 }
Esempio n. 2
0
 /**
  * Swap object data to disk
  * Actually swaps data or only unloads it from memory,
  * if object is not changed since last swap
  *
  * @param \Zend\Memory\Container\Movable $container
  * @param int $id
  */
 private function _swap(Container\Movable $container, $id)
 {
     if ($container->isLocked()) {
         return;
     }
     if (!$container->isSwapped()) {
         $this->cache->setItem($this->managerId . $id, $container->getRef());
     }
     $this->memorySize -= $this->sizes[$id];
     $container->markAsSwapped();
     $container->unloadValue();
 }