Search code examples
redispredis

No value stored in redis using predis library


Here is my current code:

$conf=[
  'scheme'=>'tcp',
  'host'=>'127.0.0.1',
  'port'=>'6379'
];
$client = new Predis\Client($conf);
$client->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut');

Here is the response from the cli:

127.0.0.1:6379> hgetall metavars;
(empty list or set)

Not sure what's wrong here, but the value is not storing in the database from using predis. If I do it manually in the cli it works fine.


Solution

  • You've added a semicolon to the key's name -- "metavars" and "metavars;" are two different keys, the former you set in your code and the latter apparently doesn't exist.