| Class | ActiveRecord::Base |
| In: |
lib/cachetastic/rails_extensions/active_record_base.rb
|
| Parent: | Object |
Returns an object from the cache for a given key. If the object returned is nil and the self_populate parameter is true then the key will be used to try and find the object in the database, set the object into the cache, and then return the object.
# File lib/cachetastic/rails_extensions/active_record_base.rb, line 13
13: def self.get_from_cache(key, self_populate = false)
14: res = cache_class.get(key)
15: if res.nil? && self_populate
16: res = self.name.constantize.find(key)
17: unless res.nil?
18: res.cache_self
19: end
20: end
21: res
22: end