mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
users can provide optional expression cache
This commit is contained in:
@@ -89,7 +89,9 @@ module Liquid
|
||||
|
||||
# Cache only exists during parsing
|
||||
if cache
|
||||
cache.fetch(markup) { inner_parse(markup, ss, cache).freeze }
|
||||
return cache[markup] if cache.key?(markup)
|
||||
|
||||
cache[markup] = inner_parse(markup, ss, cache).freeze
|
||||
else
|
||||
inner_parse(markup, ss, nil).freeze
|
||||
end
|
||||
|
||||
@@ -15,7 +15,10 @@ module Liquid
|
||||
# constructing new StringScanner in Lexer, Tokenizer, etc is expensive
|
||||
# This StringScanner will be shared by all of them
|
||||
@string_scanner = StringScanner.new("")
|
||||
@expression_cache = LruRedux::Cache.new(10_000)
|
||||
|
||||
@expression_cache = if options[:expression_cache] != false
|
||||
options[:expression_cache] || LruRedux::Cache.new(10_000)
|
||||
end
|
||||
|
||||
self.depth = 0
|
||||
self.partial = false
|
||||
|
||||
Reference in New Issue
Block a user