I have a rails ActiveRecord Model which is stored in MongoDB. Upon create/update/delete I have to update Redis data based on the model data. It's not a cache data we need it to be present.
Current code is something like this
Class Person
include Mongoid::Document
after_save do
REDIS_POOL.with { |conn| do_something(conn, instance) }
end
end
The problem here is when we do update multiple records in a loop I believe we would be creating unnecessary Redis connection which could have been done with a single connection.
Is there any way to avoid it?