soveran/ohm — pull request #37 by tcnijmeijer (2011-10-21 09:33:19+00:00)
Title: Make update indices atomic

A small change to Ohm::Model#update_indices making the update operation atomic using the redis MULTI/EXEC command. In the old implementation a model instance was temporarily absent from the indices during the update. Because of this another process would not find the model instance during that moment even though it should be.

The old indices are read outside of the multi block because the redis gem pipelines this block. Because of this its impossible to read and use a redis key inside of the same block.

To be honest it seems to me the entire save/create operation should be atomic using the MULTI/EXEC command. This would require a more extensive restructuring though so I have not gone that far.