getScopedLocks pull lock from the map if found or create a new one
(key string)
| 89 | |
| 90 | // getScopedLocks pull lock from the map if found or create a new one |
| 91 | func (f *FileCache) getScopedLocks(key string) (lock sync.Locker) { |
| 92 | f.scopedLocks.Do(func() { f.scopedLocks.locks = map[string]sync.Locker{} }) |
| 93 | |
| 94 | f.scopedLocks.Lock() |
| 95 | lock, ok := f.scopedLocks.locks[key] |
| 96 | if !ok { |
| 97 | lock = &sync.Mutex{} |
| 98 | f.scopedLocks.locks[key] = lock |
| 99 | } |
| 100 | f.scopedLocks.Unlock() |
| 101 | |
| 102 | return lock |
| 103 | } |
| 104 | |
| 105 | func (f *FileCache) getFileName(key string) string { |
| 106 | hasher := sha1.New() |