Skip to content

Instantly share code, notes, and snippets.

@tyabe
Created December 7, 2014 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyabe/21303929625223bd9c2a to your computer and use it in GitHub Desktop.
Save tyabe/21303929625223bd9c2a to your computer and use it in GitHub Desktop.
padrino-cache with sinatra
RACK_ENV = ENV['RACK_ENV'] ||= 'development' unless defined?(RACK_ENV)
APP_ROOT = File.expand_path('../..', __FILE__) unless defined?(APP_ROOT)
require 'bundler/setup'
Bundler.require(:default, RACK_ENV)
require 'padrino-core'
Padrino::IGNORE_NO_RENDERING_ENGINE = true
require 'padrino-cache'
class App < Sinatra::Base
register Padrino::Routing
register Padrino::Cache
enable :caching
enable :logging
set :protect_from_csrf, false
def logger
Padrino.logger
end
get '/', cache: true do
expires 10
Time.now.to_s
end
end
App.run!
source "https://rubygems.org"
gem 'sinatra', require: 'sinatra/base'
gem 'padrino-cache', require: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment