MCPcopy Index your code
hub / github.com/git-bug/git-bug / Resolve

Method Resolve

cache/subcache.go:352–377  ·  view source on GitHub ↗

Resolve retrieve an entity matching the exact given id

(id entity.Id)

Source from the content-addressed store, hash-verified

350
351// Resolve retrieve an entity matching the exact given id
352func (sc *SubCache[EntityT, ExcerptT, CacheT]) Resolve(id entity.Id) (CacheT, error) {
353 sc.mu.RLock()
354 cached, ok := sc.cached[id]
355 if ok {
356 sc.lru.Get(id)
357 sc.mu.RUnlock()
358 return cached, nil
359 }
360 sc.mu.RUnlock()
361
362 e, err := sc.actions.ReadWithResolver(sc.repo, sc.resolvers(), id)
363 if err != nil {
364 return *new(CacheT), err
365 }
366
367 cached = sc.makeCached(e, sc.entityUpdated)
368
369 sc.mu.Lock()
370 sc.cached[id] = cached
371 sc.lru.Add(id)
372 sc.mu.Unlock()
373
374 sc.evictIfNeeded()
375
376 return cached, nil
377}
378
379// ResolvePrefix retrieve an entity matching an id prefix. It fails if multiple
380// entities match.

Callers 1

ResolveMatcherMethod · 0.95

Calls 4

evictIfNeededMethod · 0.95
GetMethod · 0.80
AddMethod · 0.80
LockMethod · 0.65

Tested by

no test coverage detected