Skip to content

Commit 42240f8

Browse files
cendhudenyeart
authored andcommitted
use HasGet() instead of Has() and Get() on fastcache lib
While getting a value, currently, we make two APIs calls to the fastcache library. This can be avoided by making a single call using the HasGet() API. This commit replaces the two APIs call with a single HasGet() call. Signed-off-by: senthil <[email protected]>
1 parent 4c8f164 commit 42240f8

File tree

1 file changed

+3
-2
lines changed
  • core/ledger/kvledger/txmgmt/statedb/statecouchdb

1 file changed

+3
-2
lines changed

core/ledger/kvledger/txmgmt/statedb/statecouchdb/cache.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,12 @@ func (c *cache) getState(chainID, namespace, key string) (*CacheValue, error) {
6363

6464
cacheKey := constructCacheKey(chainID, namespace, key)
6565

66-
if !cache.Has(cacheKey) {
66+
valBytes, exist := cache.HasGet(nil, cacheKey)
67+
if !exist {
6768
return nil, nil
6869
}
70+
6971
cacheValue := &CacheValue{}
70-
valBytes := cache.Get(nil, cacheKey)
7172
if err := proto.Unmarshal(valBytes, cacheValue); err != nil {
7273
return nil, err
7374
}

0 commit comments

Comments
 (0)