go: Clear trust cache when trust has been modified

pull/6/head
Luther Wen Xu 2019-10-11 22:54:31 +07:00
parent 423895b376
commit 75363ec5a2
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
2 changed files with 10 additions and 1 deletions

@ -25,7 +25,7 @@ func getTrustVote(targetID string) ([]int, error) {
return array, nil
}
func updateTrust(sourceID, targetID string, voteValue int) error {
func updateDbTrust(sourceID, targetID string, voteValue int) error {
rows, err := db.Query("SELECT lastUpdated FROM trustVote WHERE sourceUser=? AND targetUser=?", sourceID, targetID)
if err != nil {
return err

@ -35,3 +35,12 @@ func getTotalTrust(s *discordgo.Session) (float64, error) {
}
return total, nil
}
func updateTrust(sourceID, targetID string, voteValue int) error {
err := updateDbTrust(sourceID, targetID, voteValue)
if err != nil {
return err
}
delete(trustCache, targetID)
return nil
}