in src/statequery/cache.go [49:72]
func (cache *Cache) Get(key string) ([]string, error) {
cache.mutex.Lock()
item, ok := cache.items[key]
if !ok {
// Cache miss
cache.mutex.Unlock()
return nil, fmt.Errorf("key not in cache: %s", key)
}
// Cache hit
// Check cache freshness
diff := time.Now().UTC().Sub(item.updated)
if diff >= cache.maxTTL {
// Cache is stale
delete(cache.items, key)
cache.mutex.Unlock()
return nil, fmt.Errorf("cache appears stale for key: %s", key)
}
// Cache item OK
cache.mutex.Unlock()
return cache.items[key].projects, nil
}