public function testHas()
 {
     $cache = new \Jenner\SimpleFork\Cache\SharedMemory();
     $cache->set('test', 'test');
     $this->assertTrue($cache->has('test'));
     $this->assertEquals($cache->get('test'), 'test');
     $cache->delete('test');
     $this->assertFalse($cache->has('test'));
 }
Exemplo n.º 2
0
 public function testOn()
 {
     $process = new \Jenner\SimpleFork\Process(function () {
     });
     $process->on(\Jenner\SimpleFork\Process::BEFORE_START, function () {
         $cache = new \Jenner\SimpleFork\Cache\SharedMemory();
         $cache->set('test', 'test');
         return true;
     });
     $process->on(\Jenner\SimpleFork\Process::BEFORE_EXIT, function () {
         $cache = new \Jenner\SimpleFork\Cache\SharedMemory();
         $cache->delete('test');
         sleep(3);
         return true;
     });
     $cache = new \Jenner\SimpleFork\Cache\SharedMemory();
     if ($cache->has('test')) {
         $cache->delete('test');
     }
     $process->start();
     sleep(1);
     $this->assertEquals('test', $cache->get('test'));
     $cache->delete('test');
 }