You can clone with
No one assigned
Is Markdown threadsafe? Should I be instantiating Redcarpet::Markdown for the entire Rails application? Or should I instantiate it once per web request?
Basically, where do I put the following code in my Rails application?
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML
+1. I would also like to know.
I use @@markdown ||= Redcarpet::Markdown.new(... to create a class variable within my helper. e.g :.
@@markdown ||= Redcarpet::Markdown.new(
@@markdown ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)
Unless explicitly stated, you should not assume any library is thread safe. That being said, there is no thread safety that I've seen built into Redcarpet itself. Consider it not thread safe and follow @Tuckie's suggestion of a class variable that is memoized to be how you should do it.
@mattr - if it's not thread safe why are you suggesting class variables? Are they not shared among threads?