From 75363ec5a257ecbb99c80feec4563c036ba87cb4 Mon Sep 17 00:00:00 2001 From: Luther Wen Xu Date: Fri, 11 Oct 2019 22:54:31 +0800 Subject: [PATCH] go: Clear trust cache when trust has been modified --- GoBot/db_trust.go | 2 +- GoBot/trust.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/GoBot/db_trust.go b/GoBot/db_trust.go index cfa4abe..1a7743d 100644 --- a/GoBot/db_trust.go +++ b/GoBot/db_trust.go @@ -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 diff --git a/GoBot/trust.go b/GoBot/trust.go index c487bf6..9fe2bb1 100644 --- a/GoBot/trust.go +++ b/GoBot/trust.go @@ -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 +}