本文整理汇总了PHP中Predis\ClientInterface::lindex方法的典型用法代码示例。如果您正苦于以下问题:PHP ClientInterface::lindex方法的具体用法?PHP ClientInterface::lindex怎么用?PHP ClientInterface::lindex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predis\ClientInterface
的用法示例。
在下文中一共展示了ClientInterface::lindex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testListSet
/**
* @group redis-lists
*/
public function testListSet()
{
try {
$this->client->lset('foo', 0, 'bar');
$this->fail('lset on non-existent list should throw exception');
} catch (Predis\Response\ServerException $e) {
if ($e->getMessage() !== 'ERR no such key') {
$this->fail('Wrong exception was thrown');
}
}
$this->client->rpush('foo', 'A', 'B', 'C');
$this->assertEquals('OK', $this->client->lset('foo', 0, 'bar'));
$this->assertSame('bar', $this->client->lindex('foo', 0));
try {
$this->assertEquals('OK', $this->client->lset('foo', 100, 'bar'));
$this->fail('lset with index out of range should throw exception');
} catch (Predis\Response\ServerException $e) {
if ($e->getMessage() !== 'ERR index out of range') {
$this->fail('Wrong exception was thrown');
}
}
}
示例2: lindex
/**
* {@inheritDoc}
*/
public function lindex($key, $index)
{
return $this->predis->lindex($key, $index);
}