Module: MongoMapper::Plugins::Caching::InstanceMethods

Defined in:
lib/mongo_mapper/plugins/caching.rb

Instance Method Summary collapse

Instance Method Details

#cache_key(*suffixes) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/mongo_mapper/plugins/caching.rb', line 6

def cache_key(*suffixes)
  cache_key = case
                when new?
                  "#{self.class.name}/new"
                when timestamp = self[:updated_at]
                  "#{self.class.name}/#{id}-#{timestamp.to_s(:number)}"
                else
                  "#{self.class.name}/#{id}"
              end
  cache_key += "/#{suffixes.join('/')}" unless suffixes.empty?
  cache_key
end