What sessions mainly do are identity map and unit of work.
Session is an object which manages Python objects that represent Redis values e.g. lists, sets, hashes. It maintains identity maps between Redis values and Python objects, and deals with transactions.
Parameters: | client (redis.client.StrictRedis) – the Redis client |
---|
(Transaction) The current transaction. It could be None when it’s not on any transaction.
Loads the value from the key. If value_type is present the value will be treated as it, or ByteString by default.
Parameters: |
|
---|---|
Returns: | the loaded value |
Marks it is manipulative.
Parameters: | keys (collections.Iterable) – optional set of keys to watch |
---|
Note
This method is for internal use.
Marks it is querying.
Parameters: | keys (collections.Iterable) – optional set of keys to watch |
---|---|
Raises sider.exceptions.CommitError: | |
when it is tried during commit phase |
Note
This method is for internal use.
(str) Redis server version string e.g. '2.2.11'.
(tuple) Redis server version triple e.g. (2, 2, 11). You can compare versions using this property.
Stores the value into the key. If value_type is present the value will be treated as it, or ByteString by default.
Parameters: |
|
---|---|
Returns: | the Python representation of the saved value. it is equivalent to the given value but may not equal nor the same to |
(sider.transaction.Transaction) The transaction object for the session.
Transaction objects are callable and so you can use this transaction property as like a method:
def block(trial, transaction):
list_[0] = list_[0].upper()
session.transaction(block)
Or you can use it in a for loop:
for trial in session.transaction:
list_[0] = list_[0].upper()
See also
(bool) If it is set to True, error messages raised by transactions will contain tracebacks where they started query/commit phase.
It is mostly for debug purpose, and you can set this to True if it’s needed.