mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 14:07:02 +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"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/anyproto/any-sync/app/logger"
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
|
||||||
|
"github.com/anyproto/any-sync/app/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -137,10 +138,11 @@ Load:
|
||||||
if reload {
|
if reload {
|
||||||
goto Load
|
goto Load
|
||||||
}
|
}
|
||||||
if load {
|
|
||||||
go c.load(ctx, id, e)
|
|
||||||
}
|
|
||||||
c.metricsGet(!load)
|
c.metricsGet(!load)
|
||||||
|
if load {
|
||||||
|
c.load(ctx, id, e)
|
||||||
|
return e.value, e.loadErr
|
||||||
|
}
|
||||||
return e.waitLoad(ctx, id)
|
return e.waitLoad(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,9 @@ func TestOCache_Get(t *testing.T) {
|
||||||
t.Run("context cancel", func(t *testing.T) {
|
t.Run("context cancel", func(t *testing.T) {
|
||||||
c := New(func(ctx context.Context, id string) (value Object, err error) {
|
c := New(func(ctx context.Context, id string) (value Object, err error) {
|
||||||
time.Sleep(time.Second / 3)
|
time.Sleep(time.Second / 3)
|
||||||
|
if ctx.Err() != nil {
|
||||||
|
return nil, ctx.Err()
|
||||||
|
}
|
||||||
return &testObject{
|
return &testObject{
|
||||||
name: "id",
|
name: "id",
|
||||||
}, nil
|
}, nil
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue