Closed stuaxo closed 8 years ago
Oooh - this is meant to happen, silly me :)
OK, maybe it isn't meant to happen, I'm definitely confused.
Hello
The name
field for the Bike
object is marked as unique=True
, to you cannot create two objects with the same name, so, yes, it is meant to happen.
Why did you thought the opposite?
Unfamiliarity with the database, orm and tiredness :)
Ah, I remember: I didn't think that Bike(....) would actually save to redis - I assumed an actual .save() command would need to be issued, like some other ORMs.
Limpyd is different, it works at the field level. The model is just here to group fields together, and manage the base of the redis keys.
To confirm that this kind of call does create the "instance", here is the docstring of the RedisModel.__init__
:
def __init__(self, *args, **kwargs):
"""
Init or retrieve an object storage in Redis.
Here whats init manages:
- no args, no kwargs: just instanciate in a python way, no connection to
redis
- some kwargs == instanciate, connect, and set the properties received
- one arg == get from pk
"""
(wow, pretty bad english in there....)
This makes sense, I guess due to the nature of Redis. Is there a way to batch changes together ?
yep, limpyd has you covered :)
http://redis-limpyd.readthedocs.io/en/latest/contrib.html#pipelines
But don't forget this (from the doc):
It does not mean that you cannot set many fields in one time in a pipeline, but you must have values not depending of other fields, and, also very important, you cannot update indexable fields ! (so no related fields either, because they are all indexable)
Note that as for the pipeline method, you cannot update indexables fields in the transaction because read commands are used to update them.
Cool, cheers :)
Run the mountainbike example from the github frontpage twice and this happens: