Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

optimized has_many_proxy a bit

  • Loading branch information...
commit 4bfe91f0c6d307b2bcb817aacb5bac0510943545 1 parent 50a7cdd
@german authored
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/redis_orm/associations/has_many_proxy.rb
View
6 lib/redis_orm/associations/has_many_proxy.rb
@@ -12,6 +12,10 @@ def initialize(receiver_model_name, reciever_id, foreign_models, options)
@fetched = false
end
+ def receiver_instance
+ @receiver_instance ||= @reciever_model_name.camelize.constantize.find(@reciever_id)
+ end
+
def fetch
@records = @foreign_models.to_s.singularize.camelize.constantize.find($redis.zrevrangebyscore __key__, Time.now.to_f, 0)
@fetched = true
@@ -32,7 +36,7 @@ def to_a
def <<(new_records)
new_records.to_a.each do |record|
$redis.zadd(__key__, Time.now.to_f, record.id)
- receiver_instance = @reciever_model_name.camelize.constantize.find(@reciever_id)
+
receiver_instance.set_expire_on_reference_key(__key__)
record.get_indices.each do |index|
Please sign in to comment.
Something went wrong with that request. Please try again.