diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2024-05-07 01:06:42 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-07 01:06:42 +0900 |
| commit | e8405f40fe2eb3675f1cb4f69e825eff5f13f269 (patch) | |
| tree | c917367f1f0098939f9cdf7376a2a135907024fc /src/cache.go | |
| parent | 065b9e6fb2ce3e6e50ff423c3786989afa04ee14 (diff) | |
| download | fzf-e8405f40fe2eb3675f1cb4f69e825eff5f13f269.tar.gz | |
Refactor the code so that fzf can be used as a library (#3769)
Diffstat (limited to 'src/cache.go')
| -rw-r--r-- | src/cache.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/cache.go b/src/cache.go index df1a6ab7..39d4250d 100644 --- a/src/cache.go +++ b/src/cache.go @@ -12,8 +12,14 @@ type ChunkCache struct { } // NewChunkCache returns a new ChunkCache -func NewChunkCache() ChunkCache { - return ChunkCache{sync.Mutex{}, make(map[*Chunk]*queryCache)} +func NewChunkCache() *ChunkCache { + return &ChunkCache{sync.Mutex{}, make(map[*Chunk]*queryCache)} +} + +func (cc *ChunkCache) Clear() { + cc.mutex.Lock() + cc.cache = make(map[*Chunk]*queryCache) + cc.mutex.Unlock() } // Add adds the list to the cache |
