本文整理汇总了PHP中Predis\ClientInterface::rename方法的典型用法代码示例。如果您正苦于以下问题:PHP ClientInterface::rename方法的具体用法?PHP ClientInterface::rename怎么用?PHP ClientInterface::rename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predis\ClientInterface
的用法示例。
在下文中一共展示了ClientInterface::rename方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRename
/**
* @group redis-keys
*/
public function testRename()
{
try {
$this->client->rename('foo', 'bar');
$this->fail('rename should throw exception when source does not exist');
} catch (Predis\Response\ServerException $e) {
if ($e->getMessage() !== 'ERR no such key') {
throw $e;
}
}
$this->client->set('foo', 'bar');
try {
$this->assertEquals('OK', $this->client->rename('foo', 'foo'));
$this->fail('rename should throw exception when source and destination are the same');
} catch (Predis\Response\ServerException $e) {
if ($e->getMessage() !== 'ERR source and destination objects are the same') {
throw $e;
}
}
$this->assertEquals('OK', $this->client->rename('foo', 'baz'));
$this->assertTrue($this->client->exists('baz'));
$this->assertFalse($this->client->exists('foo'));
}