summaryrefslogtreecommitdiff
path: root/src/cache.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cache.go')
-rw-r--r--src/cache.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cache.go b/src/cache.go
index 340f3258..f2f84a0a 100644
--- a/src/cache.go
+++ b/src/cache.go
@@ -2,16 +2,21 @@ package fzf
import "sync"
+// QueryCache associates strings to lists of items
type QueryCache map[string][]*Item
+
+// ChunkCache associates Chunk and query string to lists of items
type ChunkCache struct {
mutex sync.Mutex
cache map[*Chunk]*QueryCache
}
+// NewChunkCache returns a new ChunkCache
func NewChunkCache() ChunkCache {
return ChunkCache{sync.Mutex{}, make(map[*Chunk]*QueryCache)}
}
+// Add adds the list to the cache
func (cc *ChunkCache) Add(chunk *Chunk, key string, list []*Item) {
if len(key) == 0 || !chunk.IsFull() {
return
@@ -28,6 +33,7 @@ func (cc *ChunkCache) Add(chunk *Chunk, key string, list []*Item) {
(*qc)[key] = list
}
+// Find is called to lookup ChunkCache
func (cc *ChunkCache) Find(chunk *Chunk, key string) ([]*Item, bool) {
if len(key) == 0 || !chunk.IsFull() {
return nil, false