Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-01-04 21:20:58 +0300
committerRobert Speicher <rspeicher@gmail.com>2016-01-04 21:21:39 +0300
commit9c8ce4b6b5d67a76827a7589ab1de207209b7fd6 (patch)
treee06b201869996180b42cd7ee63338856792dc718
parent01824a0fac17331c7eacf40feb6882c508fe4880 (diff)
Merge branch 'debug-banzai-cache' into 'master'
Add DEBUG_BANZAI_CACHE env var to debug Banzai cache issue. See https://gitlab.com/gitlab-org/gitlab-ce/issues/4130#note_3012511 See merge request !2283
-rw-r--r--lib/banzai/renderer.rb21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/banzai/renderer.rb b/lib/banzai/renderer.rb
index 115ae914524..910e1c6994e 100644
--- a/lib/banzai/renderer.rb
+++ b/lib/banzai/renderer.rb
@@ -1,7 +1,5 @@
module Banzai
module Renderer
- CACHE_ENABLED = false
-
# Convert a Markdown String into an HTML-safe String of HTML
#
# Note that while the returned HTML will have been sanitized of dangerous
@@ -20,13 +18,22 @@ module Banzai
cache_key = context.delete(:cache_key)
cache_key = full_cache_key(cache_key, context[:pipeline])
- if cache_key && CACHE_ENABLED
- Rails.cache.fetch(cache_key) do
- cacheless_render(text, context)
+ cacheless = cacheless_render(text, context)
+
+ if cache_key && ENV["DEBUG_BANZAI_CACHE"]
+ cached = Rails.cache.fetch(cache_key) { cacheless }
+
+ if cached != cacheless
+ Rails.logger.warn "Banzai cache mismatch"
+ Rails.logger.warn "Text: #{text.inspect}"
+ Rails.logger.warn "Context: #{context.inspect}"
+ Rails.logger.warn "Cache key: #{cache_key.inspect}"
+ Rails.logger.warn "Cacheless: #{cacheless.inspect}"
+ Rails.logger.warn "With cache: #{cached.inspect}"
end
- else
- cacheless_render(text, context)
end
+
+ cacheless
end
def self.render_result(text, context = {})