This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Mongoid #:nodoc: | |
module Cache | |
extend ActiveSupport::Concern | |
included do | |
class << self | |
alias_method :original_find, :find | |
def find_with_cache(*args) | |
if args.length == 1 and (args[0].is_a? BSON::ObjectId or args[0].is_a? String) | |
Rails.cache.fetch("#{self.name}::#{args[0].to_s}") {find_without_cache *args} |
NewerOlder