Sha256: 75bc6d17f5a56b3cb41b50b02a24fe3ad819b48bab5b8c865a7f04de54c37892
Contents?: true
Size: 842 Bytes
Versions: 1
Compression:
Stored size: 842 Bytes
Contents
require 'digest/md5' module Stormy::Caches class Base def initialize(app) @app = app end def content(category,key,options={},&block) data = self.get(category,key) if !data.nil? log "Cache Hit: #{category} #{key}" data else log "Cache Miss: #{category} #{key}" self.put(category,key,yield(options)) end end def page(key,&block) content("_pages",key,&block) end def layout(key,&block) content("_layouts",key,&block) end def content_list(category,options = {}, &block) content("list-#{category}",hash_options(options),&block) end def log(str) #puts str end protected def hash_options(options) Digest::MD5.hexdigest(options.to_a.sort_by { |key,val| key }.to_json) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stormy-0.0.1 | lib/stormy/caches/base.rb |