Search code examples
rubyredisohm

Doing a batch delete in redis with ohm


Is there a way to delete multiple objects in redis via the ruby gem ohm? Right now to delete multiple data we do a loop and call object.delete each one of them. I would appreciate if anyone could point me to the right direction.


Solution

  • There doesn't appear to be a way to do this with Ohm directly, but you can drop down to the base redis gem and do it that way as Redis supports multiple keys with the delete command.

    So, something like this:

    Model.redis.delete *records.map(&:id)