/**
  * tests the value access methods
  */
 public function testValueAccess()
 {
     $memoryManager = new Zend_Memory_Manager_Dummy();
     $memObject = new Zend_Memory_Container_Movable($memoryManager, 10, '0123456789');
     // getRef() method
     $this->assertEquals($memObject->getRef(), '0123456789');
     $valueRef =& $memObject->getRef();
     $valueRef[3] = '_';
     $this->assertEquals($memObject->getRef(), '012_456789');
     if (version_compare(PHP_VERSION, '5.2') < 0) {
         // Skip next tests for PHP versions before 5.2
         return;
     }
     // 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');
 }
Beispiel #2
0
 /**
  * Swap object data to disk
  * Actualy swaps data or only unloads it from memory,
  * if object is not changed since last swap
  *
  * @param Zend_Memory_Container_Movable $container
  * @param integer $id
  */
 private function _swap(Zend_Memory_Container_Movable $container, $id)
 {
     if ($container->isLocked()) {
         return;
     }
     if (!$container->isSwapped()) {
         $this->_backend->save($container->getRef(), $this->_managerId . $id, $this->_tags);
     }
     $this->_memorySize -= $this->_sizes[$id];
     $container->markAsSwapped();
     $container->unloadValue();
 }