Created
December 7, 2014 16:33
-
-
Save tyabe/21303929625223bd9c2a to your computer and use it in GitHub Desktop.
padrino-cache with sinatra
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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