MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / NewInMemoryCache

Function NewInMemoryCache

pkg/auth/rights/cache.go:108–121  ·  view source on GitHub ↗

NewInMemoryCache returns a new in-memory cache on top of the given fetcher. Successful responses are valid for the duration of successTTL, unsuccessful responses are valid for the duration of errorTTL.

(fetcher Fetcher, successTTL, errorTTL time.Duration)

Source from the content-addressed store, hash-verified

106// Successful responses are valid for the duration of successTTL, unsuccessful
107// responses are valid for the duration of errorTTL.
108func NewInMemoryCache(fetcher Fetcher, successTTL, errorTTL time.Duration) Fetcher {
109 return &inMemoryCache{
110 Fetcher: fetcher,
111 successTTL: successTTL,
112 errorTTL: errorTTL,
113 lastCleanup: now(),
114 authInfo: make(map[cachedReq]*cachedAuthInfoRes),
115 applicationRights: make(map[cachedReq]*cachedRes),
116 clientRights: make(map[cachedReq]*cachedRes),
117 gatewayRights: make(map[cachedReq]*cachedRes),
118 organizationRights: make(map[cachedReq]*cachedRes),
119 userRights: make(map[cachedReq]*cachedRes),
120 }
121}
122
123type inMemoryCache struct {
124 Fetcher

Callers 2

TestCacheFunction · 0.92
initRightsMethod · 0.92

Calls 1

nowFunction · 0.85

Tested by 1

TestCacheFunction · 0.74