/** * @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'); } } }
/** * {@inheritDoc} */ public function lindex($key, $index) { return $this->predis->lindex($key, $index); }