Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions caching_compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import (
"github.com/karlseguin/ccache/v2"
)

var (
CacheTime = time.Hour
)
var CacheTime = time.Hour

// NewCachingCompiler returns a CELCompiler which lifts quoted literals out of the expression
// as variables and uses caching to cache expression parsing, resulting in improved
Expand Down Expand Up @@ -39,6 +37,10 @@ func (c *cachingCompiler) Parse(expr string) (*cel.Ast, *cel.Issues, LiftedArgs)
}

expr, vars := liftLiterals(expr)
if vars == nil {
// enusre this is never non-nil.
vars = regularArgMap{}
}

if cached := c.cache.Get("cc:" + expr); cached != nil {
cached.Extend(CacheTime)
Expand Down
1 change: 0 additions & 1 deletion expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,6 @@ func engineType(p Predicate) EngineType {
if p.Operator == operators.NotEquals || p.Operator == operators.In {
return EngineTypeNone
}
// return EngineTypeNone
return EngineTypeBTree
case string:
if len(v) == 0 {
Expand Down