工具函数
(lockKey string, fn func() error)
| 170 | // 工具函数 |
| 171 | |
| 172 | func (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 | |
| 181 | func (h *historyCache) handleEmptyOrError(ctx context.Context, key string, values []string, err error) bool { |
| 182 | if errors.Is(err, redis.Nil) || len(values) == 0 { |
no outgoing calls
no test coverage detected