Skip to content

Commit

Permalink
replaced and removed useless field in RemoteCache
Browse files Browse the repository at this point in the history
Signed-off-by: vanceli <vanceli@tencent.com>
  • Loading branch information
vanceli authored and twpayne committed May 26, 2021
1 parent e19f8c1 commit bc06f49
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions pkg/allocator/allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -882,8 +882,7 @@ type AllocatorEvent struct {
// identities. The contents are not directly accessible but will be merged into
// the ForeachCache() function.
type RemoteCache struct {
cache cache
allocator *Allocator
cache cache
}

// WatchRemoteKVStore starts watching an allocator base prefix the kvstore
Expand All @@ -893,8 +892,7 @@ type RemoteCache struct {
// function.
func (a *Allocator) WatchRemoteKVStore(remoteAlloc *Allocator) *RemoteCache {
rc := &RemoteCache{
cache: newCache(remoteAlloc),
allocator: remoteAlloc,
cache: newCache(remoteAlloc),
}

a.remoteCachesMutex.Lock()
Expand All @@ -918,9 +916,9 @@ func (rc *RemoteCache) NumEntries() int {
// Close stops watching for identities in the kvstore associated with the
// remote cache and will clear the local cache.
func (rc *RemoteCache) Close() {
rc.allocator.remoteCachesMutex.Lock()
delete(rc.allocator.remoteCaches, rc)
rc.allocator.remoteCachesMutex.Unlock()
rc.cache.allocator.remoteCachesMutex.Lock()
delete(rc.cache.allocator.remoteCaches, rc)
rc.cache.allocator.remoteCachesMutex.Unlock()

rc.cache.stop()
}

0 comments on commit bc06f49

Please sign in to comment.