MrBinWin
MrBinWin

Reputation: 1319

Call a redis command outside of transaction context

Is it possible to call a predis command outside of transaction context? I mean to exec hget or hexist while a transaction is opened

Upvotes: 0

Views: 112

Answers (2)

Ofir Luzon
Ofir Luzon

Reputation: 10907

You can do it, but not on the same connection.

Here's a transaction that copies foo2 value to foo, foo2 is read by a second connection:

$responses = $client1->transaction()->set('foo', $client2->get('foo2'))->get('foo')->execute();

Upvotes: 0

Nick Bondarenko
Nick Bondarenko

Reputation: 6351

No, it`s not possible. Transaction started with (MULTI) works in per connection pipeline. So you should DISCARD/EXEC first or use another predis connection to Redis server.

Upvotes: 2

Related Questions