Skip to content

Instantly share code, notes, and snippets.

View jonlives's full-sized avatar

Jon Cowie jonlives

View GitHub Profile
@jonlives
jonlives / cache_helper.rb
Created January 22, 2012 14:19 — forked from bryanthompson/cache_helper.rb
Simple fragment caching in sinatra
require 'sinatra/base'
class CacheHelper
module Sinatra
module Helpers
def cache(name, options = {}, &block)
if cache = read_fragment(name, options)
@_out_buf << cache
else
pos = @_out_buf.length