예제 #1
0
 public function testScalars()
 {
     // Basic get/set
     $this->credis->set('foo', 'FOO');
     $this->assertEquals('FOO', $this->credis->get('foo'));
     $this->assertFalse($this->credis->get('nil'));
     // Empty string
     $this->credis->set('empty', '');
     $this->assertEquals('', $this->credis->get('empty'));
     // UTF-8 characters
     $utf8str = str_repeat("quarter: ¼, micro: µ, thorn: Þ, ", 500);
     $this->credis->set('utf8', $utf8str);
     $this->assertEquals($utf8str, $this->credis->get('utf8'));
     // Array
     $this->assertTrue($this->credis->mSet(array('bar' => 'BAR', 'apple' => 'red')));
     $mGet = $this->credis->mGet(array('foo', 'bar', 'empty'));
     $this->assertTrue(in_array('FOO', $mGet));
     $this->assertTrue(in_array('BAR', $mGet));
     $this->assertTrue(in_array('', $mGet));
     // Non-array
     $mGet = $this->credis->mGet('foo', 'bar');
     $this->assertTrue(in_array('FOO', $mGet));
     $this->assertTrue(in_array('BAR', $mGet));
     // Delete strings, null response
     $this->assertEquals(2, $this->credis->del('foo', 'bar'));
     $this->assertFalse($this->credis->get('foo'));
     $this->assertFalse($this->credis->get('bar'));
     // Long string
     $longString = str_repeat(md5('asd'), 4096);
     // 128k (redis.h REDIS_INLINE_MAX_SIZE = 64k)
     $this->assertTrue($this->credis->set('long', $longString));
     $this->assertEquals($longString, $this->credis->get('long'));
 }