aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2021-10-24 13:10:20 -0400
committerMitchell Riedstra <mitch@riedstra.dev>2021-10-24 13:10:20 -0400
commite0d4a3e50921dc07e23ef9aa107bdc78b3adf176 (patch)
tree3b7abcbc091cafd7591e91d0ad96e3b5760f3ba5 /cmd
parent268fcf7e6b671d4959a12111d5abf553bf0a201b (diff)
downloadgo-website-e0d4a3e50921dc07e23ef9aa107bdc78b3adf176.tar.gz
go-website-e0d4a3e50921dc07e23ef9aa107bdc78b3adf176.tar.xz
Use hash in redis. Key can be set in conf.v0.0.15
Diffstat (limited to 'cmd')
-rw-r--r--cmd/server/app.go1
-rw-r--r--cmd/server/handlers.go2
-rw-r--r--cmd/server/main.go8
3 files changed, 8 insertions, 3 deletions
diff --git a/cmd/server/app.go b/cmd/server/app.go
index 290b44a..c4992ae 100644
--- a/cmd/server/app.go
+++ b/cmd/server/app.go
@@ -13,6 +13,7 @@ var FeedPrefixDefault = ".feeds"
type App struct {
redisPool *redis.Pool
+ RedisKey string
ReIndexPath string
StaticDirectory string
diff --git a/cmd/server/handlers.go b/cmd/server/handlers.go
index 869e5ba..61bb623 100644
--- a/cmd/server/handlers.go
+++ b/cmd/server/handlers.go
@@ -19,7 +19,7 @@ func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if a.redisPool != nil {
rtr.PathPrefix("/").Handler(rediscache.Handle(
- a.redisPool, http.HandlerFunc(a.PageHandler)))
+ a.redisPool, a.RedisKey, http.HandlerFunc(a.PageHandler)))
} else {
rtr.PathPrefix("/").Handler(http.HandlerFunc(a.PageHandler))
}
diff --git a/cmd/server/main.go b/cmd/server/main.go
index d76f938..21f7031 100644
--- a/cmd/server/main.go
+++ b/cmd/server/main.go
@@ -34,8 +34,8 @@ func main() { //nolint:funlen
indexPath := fl.String("i", defaultIndexPath,
"Path in which, when called will rebuild the index and clear the cache")
- redisAddr := fl.String("r", "127.0.0.1:6379",
- "Redis server set to \"\" to disable")
+ redisAddr := fl.String("r", "127.0.0.1:6379", "Redis server set to \"\" to disable")
+ redisKey := fl.String("rk", "go-website", "Redis key to use for storing cached pages")
pageTimeout := fl.Int("timeout", 15, "Seconds until page timeout for read and write")
@@ -63,6 +63,10 @@ func main() { //nolint:funlen
app.ReIndexPath = *indexPath
}
+ if app.RedisKey == "" {
+ app.RedisKey = *redisKey
+ }
+
if *redisAddr != "" {
app.redisPool = &redis.Pool{
MaxIdle: 80, //nolint:gomnd