aboutsummaryrefslogtreecommitdiff
path: root/cmd/server/app.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/server/app.go')
-rw-r--r--cmd/server/app.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/cmd/server/app.go b/cmd/server/app.go
index c4992ae..4f62a09 100644
--- a/cmd/server/app.go
+++ b/cmd/server/app.go
@@ -2,6 +2,7 @@ package main
import (
"fmt"
+ "log"
"os"
"github.com/gomodule/redigo/redis"
@@ -72,3 +73,21 @@ func loadConf(fn string) (*App, error) {
return app, nil
}
+
+// ClearRedis is a little helper function that allows us to easily clear
+// the redis cache at runtime.
+func (a *App) ClearRedis() error {
+ if a.redisPool == nil {
+ return nil
+ }
+
+ client := a.redisPool.Get()
+ defer client.Close()
+
+ _, err := client.Do("DEL", a.RedisKey)
+ if err != nil {
+ log.Println("Encountered error clearing redis cache: ", err)
+ }
+
+ return fmt.Errorf("clearing redis: %w", err)
+}