Don't prematurely load topics just to increment their cached view counts.

This commit is contained in:
Azareal 2018-09-11 22:21:15 +10:00
parent 01040b200d
commit 646c1f2545
1 changed files with 10 additions and 4 deletions

View File

@ -81,17 +81,23 @@ func (counter *DefaultTopicViewCounter) insertChunk(count int, topicID int) erro
if count == 0 {
return nil
}
common.DebugLogf("Inserting %d views into topic %d", count, topicID)
_, err := counter.update.Exec(count, topicID)
if err != nil {
return err
}
// TODO: Add a way to disable this for extra speed ;)
topic, err := common.Topics.Get(topicID)
tcache := common.Topics.GetCache()
if tcache != nil {
topic, err := tcache.Get(topicID)
if err != nil {
return err
}
atomic.AddInt64(&topic.ViewCount, int64(count))
}
return nil
}