Skip to content

Commit 5dc3f74

Browse files
adonovangopherbot
authored andcommitted
gopls/internal/lsp/filecache: reenable memory cache layer
Change-Id: I6814cb365f81e740e98cd9fa0c723256b69141aa Reviewed-on: https://go-review.googlesource.com/c/tools/+/497955 Reviewed-by: Robert Findley <[email protected]> TryBot-Result: Gopher Robot <[email protected]> gopls-CI: kokoro <[email protected]> Auto-Submit: Alan Donovan <[email protected]> Run-TryBot: Alan Donovan <[email protected]>
1 parent 7e146a6 commit 5dc3f74

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

gopls/internal/lsp/filecache/filecache.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ type memKey struct {
5959
key [32]byte
6060
}
6161

62-
const useMemCache = false // disabled for now while we debug the new file-based implementation
63-
6462
// Get retrieves from the cache and returns a newly allocated
6563
// copy of the value most recently supplied to Set(kind, key),
6664
// possibly by another process.
@@ -69,10 +67,8 @@ func Get(kind string, key [32]byte) ([]byte, error) {
6967
// First consult the read-through memory cache.
7068
// Note that memory cache hits do not update the times
7169
// used for LRU eviction of the file-based cache.
72-
if useMemCache {
73-
if value := memCache.Get(memKey{kind, key}); value != nil {
74-
return value.([]byte), nil
75-
}
70+
if value := memCache.Get(memKey{kind, key}); value != nil {
71+
return value.([]byte), nil
7672
}
7773

7874
iolimit <- struct{}{} // acquire a token
@@ -130,9 +126,7 @@ func Get(kind string, key [32]byte) ([]byte, error) {
130126
touch(indexName)
131127
touch(casName)
132128

133-
if useMemCache {
134-
memCache.Set(memKey{kind, key}, value, len(value))
135-
}
129+
memCache.Set(memKey{kind, key}, value, len(value))
136130

137131
return value, nil
138132
}
@@ -143,9 +137,7 @@ var ErrNotFound = fmt.Errorf("not found")
143137

144138
// Set updates the value in the cache.
145139
func Set(kind string, key [32]byte, value []byte) error {
146-
if useMemCache {
147-
memCache.Set(memKey{kind, key}, value, len(value))
148-
}
140+
memCache.Set(memKey{kind, key}, value, len(value))
149141

150142
iolimit <- struct{}{} // acquire a token
151143
defer func() { <-iolimit }() // release a token

0 commit comments

Comments
 (0)