Skip to content

Commit 521ca10

Browse files
committed
fixes for feedback
1 parent 5c2a1ba commit 521ca10

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

backend/instancemgmt/instance_manager.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ func (im *instanceManager) Get(ctx context.Context, pluginContext backend.Plugin
115115
}
116116
// Double-checked locking for update/create criteria
117117
strKey := fmt.Sprintf("%v", cacheKey)
118-
im.locker.RLock(strKey)
119118
item, ok := im.cache.Get(strKey)
120-
im.locker.RUnlock(strKey)
121119

122120
if ok {
123121
ci := item.(CachedInstance)
@@ -146,10 +144,10 @@ func (im *instanceManager) Get(ctx context.Context, pluginContext backend.Plugin
146144
if err != nil {
147145
return nil, err
148146
}
149-
im.cache.Set(strKey, CachedInstance{
147+
im.cache.SetDefault(strKey, CachedInstance{
150148
PluginContext: pluginContext,
151149
instance: instance,
152-
}, gocache.DefaultExpiration)
150+
})
153151
activeInstances.Inc()
154152

155153
return instance, nil

backend/instancemgmt/instance_manager_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func TestInstanceManagerExpiration(t *testing.T) {
7575
}
7676

7777
tip := &testInstanceProvider{}
78-
im := NewWithOptions(tip, time.Millisecond, 2*time.Millisecond, defaultDisposeTTL)
78+
im := NewWithOptions(tip, time.Millisecond, 2*time.Millisecond, 10*time.Millisecond)
7979

8080
instance, err := im.Get(ctx, pCtx)
8181
require.NoError(t, err)

0 commit comments

Comments
 (0)