Ejemplo n.º 1
0
 public function testForcePHPArrayFlag()
 {
     ArrayFactory::setForcePHPArray(false);
     $this->assertInstanceOf('\\Limcache\\storage\\JudyArray', ArrayFactory::createArray(ArrayFactory::STRING_TO_MIXED));
     ArrayFactory::setForcePHPArray(true);
     $this->assertInstanceOf('\\Limcache\\storage\\PHPArray', ArrayFactory::createArray(ArrayFactory::STRING_TO_MIXED));
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider forcePHPArrayProvider
  */
 public function testEvictionOnRead($forcePHPArray)
 {
     ArrayFactory::setForcePHPArray($forcePHPArray);
     $strategy = new MRU(3);
     $cache = new Cache($strategy);
     $cache['key1'] = 1;
     $cache['key2'] = 2;
     $cache['key3'] = 3;
     $cache['key1'];
     // read key1
     $cache['key4'] = 4;
     $this->assertFalse(isset($cache['key1']));
     $this->assertTrue(isset($cache['key2']));
     $this->assertTrue(isset($cache['key3']));
     $this->assertTrue(isset($cache['key4']));
 }
Ejemplo n.º 3
0
 /**
  * @param EvictionStrategyInterface
  */
 public function __construct(EvictionStrategyInterface $strategy)
 {
     $this->strategy = $strategy;
     $this->cache = ArrayFactory::createArray(ArrayFactory::STRING_TO_MIXED);
 }
Ejemplo n.º 4
0
 public function __construct($size)
 {
     $this->size = $size;
     $this->keys = ArrayFactory::createArray(ArrayFactory::INT_TO_MIXED);
     $this->indexes = ArrayFactory::createArray(ArrayFactory::STRING_TO_INT);
 }