예제 #1
0
 /**
  * Test setting a value if it does not exists yet
  */
 public function testSetNx()
 {
     $this->redis->del('testSetNx');
     $isSet = $this->redis->setnx('testSetNx', 'someValue');
     $this->assertTrue($isSet, 'First time setting a key with setnx should be successful');
     $this->assertInternalType('bool', $isSet);
     $isSet = $this->redis->setnx('testSetNx', 'anotherValue');
     $this->assertFalse($isSet, 'Second time setting a key with setnx should not be successful');
     $this->assertInternalType('bool', $isSet);
     $this->assertEquals('someValue', $this->redis->get('testSetNx'), 'The second set should not have changed the value');
 }