aboutsummaryrefslogtreecommitdiff
path: root/cmd/server/app.go
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2021-10-24 15:57:32 -0400
committerMitchell Riedstra <mitch@riedstra.dev>2021-10-24 16:01:05 -0400
commit235b8f871fdfa35f9595268d194d28a3de655ec0 (patch)
tree46f562fddffd38ee10d5e3d858dd80c088879689 /cmd/server/app.go
parente0d4a3e50921dc07e23ef9aa107bdc78b3adf176 (diff)
downloadgo-website-0.0.16.tar.gz
go-website-0.0.16.tar.xz
Unix sockets for redis. Page use FS interface. Clear redis func.v0.0.16
Additionally, Funcs can be passed in.
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)
+}