Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

WATCH transactions #24

Closed
jarpineh opened this issue Dec 15, 2011 · 4 comments
Closed

WATCH transactions #24

jarpineh opened this issue Dec 15, 2011 · 4 comments

Comments

@jarpineh
Copy link

Hi.

Stdnet looks like a very powerful, yet simple ORM. I read the docs and tried looking through the code for transaction support.

I have an use case almost exactly like in the Redis docs:
http://redis.io/topics/transactions -> section on optimistic locking and check-and-set

Does transactions with Stdnet support WATCH command?

My thanks.

Jussi

@lsbardel
Copy link
Owner

Jussi,
the short answer is No.
At the moment, transactions don't use WATCH and therefore there is no guarantee that keys taking part in the transaction have changed by the time we issue the EXEC command.
The good news is, once redis 2.6 is out, there will not be a need for WATCH in stdnet.
The transaction will be issued as a lua script, atomically, with WATCH part of the script.
This will be in stdnet 0.7

@jarpineh
Copy link
Author

OK, thank you for the fast response.

I noticed that there is a redis client implementation in the stdnet. Any thoughts on using redis-py and stdnet concurrently in the same python session?

I was thinking that I could implement my data structures with stdnet, but create the CAS procedure keys directly to Redis. It looks like Redis 2.6 is not quite here yet and I'd like to get my testing underway. Thus I might use redis-py and stdnet at the same time, but with separate connections to Redis.

@lsbardel
Copy link
Owner

That should be fine. You can use stdnet to manage and retrieve your data, and use redis-py for your specific needs. You could also use the internal (redis-py) client by doing something like this:

from stdnet import getdb

rpy = getdb().redispy

or with a connection string

rpy = getdb('redis://my.host.name:6379/?db=1').redispy

@jarpineh
Copy link
Author

Great, thank you.

It seems I can use instance_keys on model instances to get the keys I want to watch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants