aboutsummaryrefslogtreecommitdiff
path: root/cmd/server
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/server')
-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