MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / withLocalLock

Method withLocalLock

internal/repository/cache/history.go:172–179  ·  view source on GitHub ↗

工具函数

(lockKey string, fn func() error)

Source from the content-addressed store, hash-verified

170// 工具函数
171
172func (h *historyCache) withLocalLock(lockKey string, fn func() error) error {
173 mu := &sync.Mutex{}
174 actual, _ := h.locks.LoadOrStore(lockKey, mu)
175 mutex := actual.(*sync.Mutex)
176 mutex.Lock()
177 defer mutex.Unlock()
178 return fn()
179}
180
181func (h *historyCache) handleEmptyOrError(ctx context.Context, key string, values []string, err error) bool {
182 if errors.Is(err, redis.Nil) || len(values) == 0 {

Callers 4

GetCacheMethod · 0.95
SetCacheMethod · 0.95
DeleteOneCacheMethod · 0.95
DeleteAllHistoryMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected