Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
From 3856f4121b5e60531572873d64335660ea42c1a6 Mon Sep 17 00:00:00 2001
From: David Debreczeni <david.debreczeni@gmail.com>
Date: Thu, 18 Aug 2011 13:53:21 +0200
Subject: [PATCH] Azt szeretem a Padrinoban, hogy letisztult...
---
config/boot.rb | 22 ++++++++++++++++++++++
results/app.rb | 2 +-
2 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/config/boot.rb b/config/boot.rb
index 8fcf0b4..5f13e88 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -65,6 +65,28 @@ CarrierWave.configure do |config|
end
module Padrino
+ module Cache
+ module Helpers
+ module Fragment
+ def cache(key, opts = nil, &block)
+ if settings.caching?
+ began_at = Time.now
+ if value = settings.cache.get(key.to_s)
+ logger.debug "GET Fragment (%0.4fms) %s" % [Time.now-began_at, key.to_s] if defined?(logger)
+ concat_content(value)
+ else
+ value = capture_html(&block)
+ settings.cache.set(key.to_s, value, opts)
+ logger.debug "SET Fragment (%0.4fms) %s" % [Time.now-began_at, key.to_s] if defined?(logger)
+ concat_content(value)
+ end
+ else
+ yield
+ end
+ end
+ end
+ end
+ end
module Admin
module AccessControl
class Base
diff --git a/results/app.rb b/results/app.rb
index e0e58cd..a370576 100644
--- a/results/app.rb
+++ b/results/app.rb
@@ -24,7 +24,7 @@ class Results < Padrino::Application
# Caching support
#
register Padrino::Cache
- enable :caching
+ enable :caching unless PADRINO_ENV == 'development'
#
# You can customize caching store engines:
#
--
1.7.6+GitX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment