(ctx context.Context, id string)
| 116 | } |
| 117 | |
| 118 | func (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. |
no test coverage detected