MCPcopy Create free account
hub / github.com/astercloud/aster / getFromMemory

Method getFromMemory

pkg/tools/cache.go:241–256  ·  view source on GitHub ↗

内存缓存操作

(key string)

Source from the content-addressed store, hash-verified

239// 内存缓存操作
240
241func (c *ToolCache) getFromMemory(key string) (any, bool) {
242 c.memoryMu.RLock()
243 defer c.memoryMu.RUnlock()
244
245 entry, ok := c.memoryCache[key]
246 if !ok {
247 return nil, false
248 }
249
250 // 检查是否过期
251 if entry.IsExpired() {
252 return nil, false
253 }
254
255 return entry.Value, true
256}
257
258func (c *ToolCache) setToMemory(key string, value any, ttl time.Duration) {
259 c.memoryMu.Lock()

Callers 2

GetMethod · 0.95

Calls 1

IsExpiredMethod · 0.80

Tested by 1