Frage

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.

War es hilfreich?

Lösung

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)

Andere Tipps

Also try,

Model.all.map &:delete

Though it may not be the best solution because it also loops through all objects, but it works or me.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top