mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-20 11:51:17 +00:00
[counter] Remove stored counter value on zero value
Rationale: The counter store is of `map[string]int64` and therefor for an non-existent counter always `0`. As that is the default behaviour we don't need to waste storage space by storing counters being `0`. Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
d51dd27630
commit
c950b2c38b
1 changed files with 5 additions and 1 deletions
6
store.go
6
store.go
|
@ -294,7 +294,11 @@ func (s *storageFile) UpdateCounter(counter string, value int64, absolute bool)
|
|||
value = s.Counters[counter] + value
|
||||
}
|
||||
|
||||
s.Counters[counter] = value
|
||||
if value == 0 {
|
||||
delete(s.Counters, counter)
|
||||
} else {
|
||||
s.Counters[counter] = value
|
||||
}
|
||||
|
||||
return errors.Wrap(s.Save(), "saving store")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue