P
P
Philip2015-06-09 15:39:58
PHP
Philip, 2015-06-09 15:39:58

How to implement a queue with Redis runtime?

It is necessary to implement a queue on Redis and not a simple one, but with an indication of the time for performing certain operations. The study of the problem showed that in Redis it is possible to set the lifetime of the key ( EXPIRE ), but how to make a callback to this event?
Or maybe this problem should be solved in some other way?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Burov, 2015-06-09
@shcherbanich

redis.io/topics/notifications

SET notify-keyspace-events Ex
SUBSRCIBE [email protected]__:expired

$redisSub = new Redis() or die("Can't create to redis database instance!\n");
$redisSub->connect('localhost', 6379) or  die("Can't connect to redis database!\n");
$redisSub->select(2) or die("Can't select database!\n");
$redisSub->setOption(Redis::OPT_READ_TIMEOUT, -1);
$redisSub->config('SET', 'notify-keyspace-events', 'Ex');
$redisSub->subscribe(['[email protected]__:expired'], 'msg'); // db 2
function msg($redisSub, $chan, $msg)  {
}

H
He11ion, 2015-06-09
@He11ion

Use Beanstalk/gearman and not suffer as an option

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question