class Sinatra::Helpers::Stream::TemplateCache
Extremely simple template cache implementation.
* Not thread-safe. * Size is unbounded. * Keys are not copied defensively, and should not be modified after being passed to #fetch. More specifically, the values returned by key#hash and key#eql? should not change.
Implementation copied from Tilt::Cache.
Public Class Methods
new()
click to toggle source
# File lib/sinatra/base.rb 952 def initialize 953 @cache = {} 954 end
Public Instance Methods
clear()
click to toggle source
Clears the cache.
# File lib/sinatra/base.rb 967 def clear 968 @cache = {} 969 end
fetch(*key) { || ... }
click to toggle source
Caches a value for key, or returns the previously cached value. If a value has been previously cached for key then it is returned. Otherwise, block is yielded to and its return value which may be nil, is cached under key and returned.
# File lib/sinatra/base.rb 960 def fetch(*key) 961 @cache.fetch(key) do 962 @cache[key] = yield 963 end 964 end