Skip to content

Commit 25500e3

Browse files
author
John Mason
committed
Specify cache length with ZOEKT_MATCHTREE_CACHE
1 parent fb42b90 commit 25500e3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

index/matchtree.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ import (
1919
"fmt"
2020
"log"
2121
"math"
22+
"os"
2223
"regexp/syntax"
24+
"strconv"
2325
"strings"
2426
"unicode/utf8"
2527

@@ -974,7 +976,15 @@ func (d *indexData) newMatchTree(q query.Q, opt matchTreeOpt) (matchTree, error)
974976
}
975977

976978
if d.docMatchTreeCache == nil {
977-
d.docMatchTreeCache = newDocMatchTreeCache(64)
979+
cacheSize := 0
980+
if v := os.Getenv("ZOEKT_MATCHTREE_CACHE"); v != "" {
981+
var err error
982+
cacheSize, err = strconv.Atoi(v)
983+
if err != nil {
984+
cacheSize = 0
985+
}
986+
}
987+
d.docMatchTreeCache = newDocMatchTreeCache(cacheSize)
978988
}
979989

980990
switch s := q.(type) {

0 commit comments

Comments
 (0)