示例#1
0
 public function testScripts()
 {
     $this->assertNull($this->credis->evalSha('1111111111111111111111111111111111111111'));
     $this->assertEquals(3, $this->credis->eval('return 3'));
     $this->assertEquals('09d3822de862f46d784e6a36848b4f0736dda47a', $this->credis->script('load', 'return 3'));
     $this->assertEquals(3, $this->credis->evalSha('09d3822de862f46d784e6a36848b4f0736dda47a'));
     $this->credis->set('foo', 'FOO');
     $this->assertEquals('FOOBAR', $this->credis->eval("return redis.call('get', KEYS[1])..ARGV[1]", 'foo', 'BAR'));
     $this->assertEquals(array(1, 2, 'three'), $this->credis->eval("return {1,2,'three'}"));
     try {
         $this->credis->eval('this-is-not-lua');
         $this->fail('Expected exception on invalid script.');
     } catch (CredisException $e) {
     }
 }