June 2017
Intermediate to advanced
536 pages
9h 49m
English
Given that Redis is a key value store, selecting keys is as easy as using a single get() method of the Redis instance:
<?phptry { $client = new Redis(); $client->connect('localhost', 6379); echo $client->get('Key3'), PHP_EOL; echo $client->get('Key5'), PHP_EOL;} catch (RedisException $e) { echo $e->getMessage(), PHP_EOL;}
This should give us the following output:

The Redis client class also provides the mget() method, which is able to fetch more than one key value at a time:
<?phptry { $client = new Redis(); $client->connect('localhost', 6379); $values = $client->mget(['Key1', 'Key2', 'Key4']); print_r($values);} catch (RedisException ...
Read now
Unlock full access