MCPcopy
hub / github.com/cilium/cilium / GetIncludeRemoteCaches

Method GetIncludeRemoteCaches

pkg/allocator/allocator.go:858–883  ·  view source on GitHub ↗

GetIncludeRemoteCaches returns the ID which is allocated to a key. Includes the caches of watched remote kvstores in the query. Returns an ID of NoID if no ID has been allocated in any remote kvstore to this key yet.

(ctx context.Context, key AllocatorKey)

Source from the content-addressed store, hash-verified

856// caches of watched remote kvstores in the query. Returns an ID of NoID if no
857// ID has been allocated in any remote kvstore to this key yet.
858func (a *Allocator) GetIncludeRemoteCaches(ctx context.Context, key AllocatorKey) (idpool.ID, error) {
859 // check main cache first
860 if id := a.mainCache.get(key.GetKey()); id != idpool.NoID {
861 return id, nil
862 }
863
864 // check remote caches
865 a.remoteCachesMutex.RLock()
866 for _, rc := range a.remoteCaches {
867 if id := rc.cache.get(key.GetKey()); id != idpool.NoID {
868 a.remoteCachesMutex.RUnlock()
869 return id, nil
870 }
871 }
872 a.remoteCachesMutex.RUnlock()
873
874 // check main backend
875 if id, err := a.backend.Get(ctx, key); id != idpool.NoID || err != nil {
876 return id, err
877 }
878
879 // we skip checking remote backends explicitly here, to avoid
880 // accidentally overloading them in case of lookups for invalid identities
881
882 return idpool.NoID, nil
883}
884
885// GetByIDIncludeRemoteCaches returns the key associated with an ID. Includes
886// the caches of watched remote kvstores in the query.

Callers 1

LookupIdentityMethod · 0.80

Calls 5

getMethod · 0.65
GetKeyMethod · 0.65
RLockMethod · 0.65
RUnlockMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected