mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
GO-1293 Remove ocache goroutine
This commit is contained in:
parent
180eb27c33
commit
0d66f3d8be
2 changed files with 9 additions and 4 deletions
|
@ -6,8 +6,9 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -137,10 +138,11 @@ Load:
|
|||
if reload {
|
||||
goto Load
|
||||
}
|
||||
if load {
|
||||
go c.load(ctx, id, e)
|
||||
}
|
||||
c.metricsGet(!load)
|
||||
if load {
|
||||
c.load(ctx, id, e)
|
||||
return e.value, e.loadErr
|
||||
}
|
||||
return e.waitLoad(ctx, id)
|
||||
}
|
||||
|
||||
|
|
|
@ -126,6 +126,9 @@ func TestOCache_Get(t *testing.T) {
|
|||
t.Run("context cancel", func(t *testing.T) {
|
||||
c := New(func(ctx context.Context, id string) (value Object, err error) {
|
||||
time.Sleep(time.Second / 3)
|
||||
if ctx.Err() != nil {
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
return &testObject{
|
||||
name: "id",
|
||||
}, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue