File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 1212| ` GITBASE_INDEX_DIR ` | directory to save indexes, default ` /var/lib/gitbase/index ` |
1313| ` GITBASE_TRACE ` | enable jaeger tracing, default disabled |
1414| ` GITBASE_READONLY ` | allow read queries only, disabling creating and deleting indexes, default disabled |
15+ | ` GITBASE_LANGUAGE_CACHE_SIZE ` | size of the cache for the ` language ` UDF. The size is the maximum number of elements kept in the cache, 10000 by default |
1516
1617### Jaeger tracing variables
1718
Original file line number Diff line number Diff line change @@ -4,19 +4,34 @@ import (
44 "encoding/binary"
55 "fmt"
66 "hash/crc32"
7+ "os"
8+ "strconv"
79
810 lru "github.com/hashicorp/golang-lru"
911 enry "gopkg.in/src-d/enry.v1"
1012 "gopkg.in/src-d/go-mysql-server.v0/sql"
1113)
1214
13- const defaultLanguageCacheSize = 10000
15+ const (
16+ languageCacheSizeKey = "GITBASE_LANGUAGE_CACHE_SIZE"
17+ defaultLanguageCacheSize = 10000
18+ )
19+
20+ func languageCacheSize () int {
21+ v := os .Getenv (languageCacheSizeKey )
22+ size , err := strconv .Atoi (v )
23+ if err != nil || size <= 0 {
24+ size = defaultLanguageCacheSize
25+ }
26+
27+ return size
28+ }
1429
1530var languageCache * lru.TwoQueueCache
1631
1732func init () {
1833 var err error
19- languageCache , err = lru .New2Q (defaultLanguageCacheSize )
34+ languageCache , err = lru .New2Q (languageCacheSize () )
2035 if err != nil {
2136 panic (fmt .Errorf ("cannot initialize language cache: %s" , err ))
2237 }
You can’t perform that action at this time.
0 commit comments