(key string)
| 64 | } |
| 65 | |
| 66 | func getCache(key string) ([]DirEntryResult, bool) { |
| 67 | cacheMu.Lock() |
| 68 | defer cacheMu.Unlock() |
| 69 | entry, ok := cache[key] |
| 70 | if !ok { |
| 71 | return nil, false |
| 72 | } |
| 73 | if time.Now().After(entry.expiration) { |
| 74 | // expired |
| 75 | cacheLRU.Remove(entry.lruElement) |
| 76 | delete(cache, key) |
| 77 | return nil, false |
| 78 | } |
| 79 | // update LRU order |
| 80 | cacheLRU.MoveToFront(entry.lruElement) |
| 81 | return entry.value, true |
| 82 | } |
| 83 | |
| 84 | func setCache(key string, value []DirEntryResult) { |
| 85 | cacheMu.Lock() |