Skip to content

Commit 5eb1eb9

Browse files
committed
gopls/internal/lsp/cache: call filecache.Set asynchronously
Change-Id: Idbdba4c6aa90c608ad537d64be5dfb0afc82048e Reviewed-on: https://go-review.googlesource.com/c/tools/+/494996 Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Alan Donovan <adonovan@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
1 parent 35fe77a commit 5eb1eb9

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

gopls/internal/lsp/cache/analysis.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"golang.org/x/tools/gopls/internal/lsp/filecache"
3232
"golang.org/x/tools/gopls/internal/lsp/protocol"
3333
"golang.org/x/tools/gopls/internal/lsp/source"
34+
"golang.org/x/tools/internal/event"
3435
"golang.org/x/tools/internal/facts"
3536
"golang.org/x/tools/internal/gcimporter"
3637
"golang.org/x/tools/internal/memoize"
@@ -454,13 +455,15 @@ func analyzeImpl(ctx context.Context, snapshot *snapshot, analyzers []*analysis.
454455
if err != nil {
455456
return nil, err
456457
}
457-
data := mustEncode(summary)
458-
if false {
459-
log.Printf("Set key=%d value=%d id=%s\n", len(key), len(data), id)
460-
}
461-
if err := filecache.Set(cacheKind, key, data); err != nil {
462-
return nil, fmt.Errorf("internal error updating shared cache: %v", err)
463-
}
458+
go func() {
459+
data := mustEncode(summary)
460+
if false {
461+
log.Printf("Set key=%d value=%d id=%s\n", len(key), len(data), id)
462+
}
463+
if err := filecache.Set(cacheKind, key, data); err != nil {
464+
event.Error(ctx, "internal error updating analysis shared cache", err)
465+
}
466+
}()
464467
}
465468

466469
// Hit or miss, we need to merge the export data from

0 commit comments

Comments
 (0)