Sha256: 461d45bc7173d4d5377c2747478d27839d15fbfd142cd8204fb88d839981fe37
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
class Cachetastic::Stores::Base attr_reader :all_options attr_reader :store_options attr_reader :servers attr_reader :name attr_reader :logging attr_reader :logger def initialize(name) @name = name configure setup if self.debug? self.logger.debug(self.name, :self, self.inspect) self.logger.debug(self.name, :options, self.all_options.inspect) end end def valid? false end [:setup, :set, :get, :delete, :expire_all].each do |meth| define_method(meth) do |*args| raise MethodNotImplemented.new(meth) end end def debug? ivar_cache(:debug) do (self.all_options["debug"] == true || false) end end def configure @all_options = Cachetastic::Stores::Base.get_options(self.name) @store_options = (self.all_options["store_options"] || {}) @servers = self.all_options["servers"] @logging = (self.all_options["logging"] || {}) @logger = Cachetastic::Logger.new(self.logging, self.name) end # def log(mess, ex = nil) # self.logging.each_pair do |n, opts| # # lm = "[CACHE]\t#{Time.now}:\t#{mess}" # lm << "\n#{ex.message}\n" << ex.backtrace.join("\n") if ex # # case opts["type"] # when "file" # File.open(opts["file"], "a") {|f| f.puts(lm)} # when "console" # puts lm # end # end # end class << self def get_options(name) options = app_config.cachetastic_default_options options.merge!(app_config.send(name.methodize + "_options") || {}) options = {"store" => "local_memory"}.merge(options) options end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cachetastic-1.0.6 | lib/stores/cachetastic_stores_base.rb |
cachetastic-1.0.5 | lib/stores/cachetastic_stores_base.rb |