Lock minor change

This commit is contained in:
teivah 2022-05-09 13:56:59 +02:00
parent d502acea3b
commit 6a199fc553
No known key found for this signature in database
GPG key ID: E27C9FE630A49EF9
2 changed files with 4 additions and 4 deletions

View file

@ -16,8 +16,8 @@ type Event struct {
}
func (c *Cache) TrimOlderThan(since time.Duration) {
c.mu.RLock()
defer c.mu.RUnlock()
c.mu.Lock()
defer c.mu.Unlock()
t := time.Now().Add(-since)
for i := 0; i < len(c.events); i++ {

View file

@ -26,8 +26,8 @@ type Event struct {
}
func (c *Cache) TrimOlderThan(since time.Duration) {
c.mu.RLock()
defer c.mu.RUnlock()
c.mu.Lock()
defer c.mu.Unlock()
t := time.Now().Add(-since)
for i := 0; i < len(c.events); i++ {