go/internal/persistent
Alan Donovan 1dfab61a48 internal/lsp/cache: use GetHandle not Bind for 5 URI-keyed maps
This change replaces the 5 remaining calls to Bind (generational
lifetime) with GetHandle (reference counting). The handles
are now stored in persistent.Maps, which simplifies the
invalidation logic.

All 5 have span.URIs as keys:
  symbolizeHandles
  parse{Mod,Work}Handles
  mod{Tidy,Why}Handles

Also, factor the functions that use these maps to have a common form:
- a fooImpl function that returns an R result and an error;
- a foo wrapper that decorates it with caching.
- a local fooResult type, defined struct{R; error} that is the cache entry.
The functions for getting/setting map entries are all inlined.
The fooHandle types are all replaced by *memoize.Handle, now that
their use is local.

No behavior change is intended.

The other uses of Bind are deleted in these CLs:
https://go-review.googlesource.com/c/tools/+/415975 (astCacheData)
https://go-review.googlesource.com/c/tools/+/415504 (actions)

Change-Id: I77cc4e828936fe171152ca13a12f7a639299e9e5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/415976
Auto-Submit: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-07-07 16:57:02 +00:00
..
map.go internal/lsp/cache: use GetHandle not Bind for 5 URI-keyed maps 2022-07-07 16:57:02 +00:00
map_test.go internal/lsp/cache: persist known subdirs 2022-07-05 19:08:32 +00:00