Liran
Liran

Reputation: 193

Stackexchange.redis lacks the "WAIT" support

i have 3 web api servers behind a load balancer which a client application is using. i am using this library to access redis cluster with one master and few slaves. the "WAIT" operation is not currently supported, and i need this functionality in order to store a newly created user session and wait until it replicates to all slaves to ensure that all following incoming calls from the client to read the session (which can come from my other application servers) won't fail (as it can try to read the key from a redis slave).

looking for some best practice for such implementation.

Upvotes: 4

Views: 1236

Answers (2)

Liran
Liran

Reputation: 193

solved it finally - there was a missing parameter for the wait

Upvotes: -1

Marc Gravell
Marc Gravell

Reputation: 1062770

WAIT is essentially a blocking operation, which violates the connection-sharing programming model that the library depends on (see more here). So no, this isn't exposed.

We are discussing ideas to allow a more versatile pool/lease model as well as the default shared model, but right now: this doesn't exist. But this is what would make blocking commands "safe".

You could issue it manually via Execute, but if you do that: you're on your own; if it explodes or causes any kind of problem... have fun with that!


The following is not supported (essentially it issues a blocking operation), but if it works - it works; if it causes problems - it causes problems:

var tran = db.CreateTransaction();
_ = tran.StringSetAsync("mykey", cacheItem);
_ = tran.ExecuteAsync("wait", 2);
tran.Execute();

Upvotes: 2

Related Questions