1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

chore: metrics performance improvements

This commit is contained in:
Ferdinand Mütsch
2022-03-19 10:30:32 +01:00
parent ec70d024fa
commit bbc85de34b
9 changed files with 751 additions and 723 deletions

View File

@@ -73,12 +73,12 @@ func (srv *HeartbeatService) InsertBatch(heartbeats []*models.Heartbeat) error {
return err
}
func (srv *HeartbeatService) Count() (int64, error) {
func (srv *HeartbeatService) Count(approximate bool) (int64, error) {
result, ok := srv.cache.Get(srv.countTotalCacheKey())
if ok {
return result.(int64), nil
}
count, err := srv.repository.Count()
count, err := srv.repository.Count(approximate)
if err == nil {
srv.cache.Set(srv.countTotalCacheKey(), count, srv.countCacheTtl())
}