MCPcopy
hub / github.com/fish2018/pansou / Has

Method Has

util/cache/disk_cache.go:233–250  ·  view source on GitHub ↗

Has 检查缓存是否存在

(key string)

Source from the content-addressed store, hash-verified

231
232// Has 检查缓存是否存在
233func (c *DiskCache) Has(key string) bool {
234 c.mutex.RLock()
235 defer c.mutex.RUnlock()
236
237 meta, exists := c.metadata[key]
238 if !exists {
239 return false
240 }
241
242 // 检查是否过期
243 if time.Now().After(meta.Expiry) {
244 // 异步删除过期项
245 go c.Delete(key)
246 return false
247 }
248
249 return true
250}
251
252// 清理过期项
253func (c *DiskCache) cleanExpired() {

Callers 1

SearchHandlerFunction · 0.45

Calls 1

DeleteMethod · 0.95

Tested by

no test coverage detected