1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-06-15 00:53:18 +02:00

Tests for fileCache

This commit is contained in:
Philipp Heckel 2022-01-08 12:14:43 -05:00
parent e7c19a2bad
commit cefe276ce5
7 changed files with 101 additions and 25 deletions

View file

@ -24,15 +24,12 @@ func NewLimiter(limit int64) *Limiter {
}
}
// Add adds n to the limiters internal value, but only if the limit has not been reached. If the limit would be
// Add adds n to the limiters internal value, but only if the limit has not been reached. If the limit was
// exceeded after adding n, ErrLimitReached is returned.
func (l *Limiter) Add(n int64) error {
l.mu.Lock()
defer l.mu.Unlock()
if l.limit == 0 {
l.value += n
return nil
} else if l.value+n <= l.limit {
if l.value+n <= l.limit {
l.value += n
return nil
} else {