Method: Redrecord::Model#add_to_cache!

Defined in:
lib/redrecord.rb

#add_to_cache!Object



131
132
133
134
135
136
137
138
139
# File 'lib/redrecord.rb', line 131

def add_to_cache!
  Redrecord.redis_op(:hmset, redrecord_key,
    *(self.class.redrecord_cached_fields.map {|f|
      aliased_target, punctuation = f.to_s.sub(/([?!=])$/, ''), $1
      val = send("#{aliased_target}_without_cache#{punctuation}")
      [f.to_s, Redrecord.marshal(val)]
    }.flatten)
  )
end