Skip to content

Instantly share code, notes, and snippets.

@toin0u
Created May 13, 2013 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toin0u/5567583 to your computer and use it in GitHub Desktop.
Save toin0u/5567583 to your computer and use it in GitHub Desktop.
When PhpRedis is set up with an Redis::OPT_PREFIX, It does set the prefix to the key and to the timeout value. To set the resolved key in an array seems fixing this issue. @see: https://github.com/nicolasff/phpredis/issues/158
<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis->setOption(Redis::OPT_PREFIX, 'foo:');
$redis->sAdd('queues', 'my-queue');
// output: "SADD" "foo:queues" "my-queue"
$redis->blpop('queue:my-queue', 5);
// output: "BLPOP" "foo:queue:my-queue" "foo:5"
$redis->blpop(array('queue:my-queue'), 5);
// output: "BLPOP" "foo:queue:my-queue" "5"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment