-
-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathcache.go
More file actions
30 lines (27 loc) · 1.28 KB
/
Copy pathcache.go
File metadata and controls
30 lines (27 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2022-2026 Princess B33f Heavy Industries / Dave Shanley
// SPDX-License-Identifier: MIT
package libopenapi
import (
"github.com/pb33f/libopenapi/datamodel/high"
highbase "github.com/pb33f/libopenapi/datamodel/high/base"
"github.com/pb33f/libopenapi/datamodel/low"
lowbase "github.com/pb33f/libopenapi/datamodel/low/base"
"github.com/pb33f/libopenapi/index"
"github.com/pb33f/libopenapi/utils"
)
// ClearAllCaches resets every global in-process cache in libopenapi.
//
// Calling it is not required to release memory: caches keyed by YAML nodes or model objects hold them weakly,
// so a document is reclaimed as soon as the caller drops it. Use it to force hashes to be recalculated after
// YAML nodes or low-level models were modified in place, or to empty the content-keyed caches (compiled
// JSONPath expressions, schema quick hashes, encoded values and remote content types). It is safe to call
// while other goroutines parse, build or compare documents.
func ClearAllCaches() {
low.ClearHashCache() // model and YAML node hashes
lowbase.ClearSchemaQuickHashMap() // SchemaQuickHashMap
index.ClearHashCache() // nodeHashCache
index.ClearContentDetectionCache()
highbase.ClearInlineRenderingTracker()
high.ClearEncodeCache()
utils.ClearJSONPathCache()
}