Skip to content

Commit cbfd76d

Browse files
committed
Move batch features into main classes and clean up
The classes I'd created originally to implement getting/setting in batches each included some logic that relied on what Redis type was being used. I realized it made more sense just to move all of that into the _RedisTypes and then implement a batch mode for RedisObject, instead of having a separate RedisObjectStream class. Essentially, now you can supply 'batch_size' and 'transaction_size' values (optionally) when instantiating a RedisObject, and this triggers batch mode -- get and set operations work in batch (a la RedisObjectStream). When the 'defer' option is also set to True, it overrides any value provided for 'transaction_size' and forces commands not to be executed. For _RedisTypes, I added a new _BatchMixin class for implementing the needed batch methods. This let me create a separate parallel chain of inheritance via _SequenceBatchMixin for the different rtypes that are sequence-like (list, zset) or partially sequence-like (hash, set, string). I also did some miscellaneous cleanup here. - Moved the option to execute set/get commands into _RedisType. This keeps all of that behavior consistent, since batch_save and batch_get must be able to trigger pipe.execute (for executing transactions). - Added tests and concrete behavior for edge cases. Index lookup values that are out of range. Errors for trying to batch get/set rtypes that do not support that (sets, encoded_objs). - Updated docstrings based on recent changes.
1 parent c354dca commit cbfd76d

2 files changed

Lines changed: 796 additions & 580 deletions

File tree

0 commit comments

Comments
 (0)