mirror of https://github.com/statping/statping
Merge pull request #130 from tufanbarisyildirim/issue/129
Lock safe delete in CacheStore.Getpull/135/head
commit
652b565d4e
|
@ -51,15 +51,15 @@ func (s Storage) Get(key string) []byte {
|
|||
|
||||
item := s.items[key]
|
||||
if item.Expired() {
|
||||
delete(s.items, key)
|
||||
CacheStorage.Delete(key)
|
||||
return nil
|
||||
}
|
||||
return item.Content
|
||||
}
|
||||
|
||||
func (s Storage) Delete(key string) {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
delete(s.items, key)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue