-
Notifications
You must be signed in to change notification settings - Fork 59
Open
Description
Hi, I thought Predis transactions were supported - is that not correct?
Here's the code I was trying to test:
function fetchMessages($redisClient) {
$messages = $redisClient->zrevrangebyscore('myqueue', time(), 0);
$queueId = 'myqueue';
foreach ($messages as $message) {
$dmes = json_decode($message, true);
$redisClient->transaction(
function ($tx) use ($dmes, $queueId, $message) {
$tx->zrem($queueId, $message);
$tx->rpush($dmes['destination'], json_encode($dmes['message']));
}
);
}
}And the test:
function testMyRedisQueue() {
$factory = new \M6Web\Component\RedisMock\RedisMockFactory();
$redis = $factory->getAdapter('Predis\Client', true, false, '', [
[ 'profile' => '3.0']
]);
$message = json_encode(['destination'=>'tq1', 'message' => ['key' => 'v'], 'timestamp' => new \DateTimeImmutable('now - 3 hours')->getTimestamp()]);
$redis->zadd('myqueue', \DateTimeImmutable('now - 3 hours')->getTimestamp(), $message);
$this->assertEquals(0, $redis->llen('tq1'));
fetchMessages($redis);
$this->assertEquals(1, $this->redis->llen('tq1'));
}I have isolated the problem to the code within the transaction call. If I run it outside the transaction then the test works. Any ideas on how to fix this?
Metadata
Metadata
Assignees
Labels
No labels