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

Method add

cache/subcache.go:448–469  ·  view source on GitHub ↗
(e EntityT)

Source from the content-addressed store, hash-verified

446}
447
448func (sc *SubCache[EntityT, ExcerptT, CacheT]) add(e EntityT) (CacheT, error) {
449 sc.mu.Lock()
450 if _, has := sc.cached[e.Id()]; has {
451 sc.mu.Unlock()
452 return *new(CacheT), fmt.Errorf("entity %s already exist in the cache", e.Id())
453 }
454
455 cached := sc.makeCached(e, sc.entityUpdated)
456 sc.cached[e.Id()] = cached
457 sc.lru.Add(e.Id())
458 sc.mu.Unlock()
459
460 sc.evictIfNeeded()
461
462 // force the write of the excerpt
463 err := sc.entityUpdated(e.Id())
464 if err != nil {
465 return *new(CacheT), err
466 }
467
468 return cached, nil
469}
470
471func (sc *SubCache[EntityT, ExcerptT, CacheT]) Remove(prefix string) error {
472 e, err := sc.ResolvePrefix(prefix)

Callers 1

NewRawMethod · 0.80

Calls 6

evictIfNeededMethod · 0.95
entityUpdatedMethod · 0.95
ErrorfMethod · 0.80
AddMethod · 0.80
LockMethod · 0.65
IdMethod · 0.65

Tested by

no test coverage detected