MCPcopy
hub / github.com/kopia/kopia / getEntriesFromCacheLocked

Method getEntriesFromCacheLocked

fs/cachefs/cache.go:118–139  ·  view source on GitHub ↗
(ctx context.Context, id string)

Source from the content-addressed store, hash-verified

116}
117
118func (c *Cache) getEntriesFromCacheLocked(ctx context.Context, id string) []fs.Entry {
119 if v, ok := c.data[id]; id != "" && ok {
120 if clock.Now().Before(v.expireAfter) {
121 c.moveToHead(v)
122
123 if c.debug {
124 log(ctx).Debugf("cache hit for %q (valid until %v)", id, v.expireAfter)
125 }
126
127 return v.entries
128 }
129
130 // time expired
131 if c.debug {
132 log(ctx).Debugf("removing expired cache entry %q after %v", id, v.expireAfter)
133 }
134
135 c.removeEntryLocked(v)
136 }
137
138 return nil
139}
140
141// getEntries consults the cache and either retrieves the contents of directory listing from the cache
142// or invokes the provides callback and adds the results to cache.

Callers 1

getEntriesMethod · 0.95

Calls 4

moveToHeadMethod · 0.95
removeEntryLockedMethod · 0.95
NowFunction · 0.92
BeforeMethod · 0.45

Tested by

no test coverage detected