From ca33a035c779ae14fb6330c8801c75f49dd1bb79 Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Sat, 7 Jan 2023 13:31:23 -0500 Subject: Add an internal caching option. It performs quite well. Also refactor and clean up most linter warnings. --- cmd/server/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'cmd/server/main.go') diff --git a/cmd/server/main.go b/cmd/server/main.go index d50c468..10bbbf0 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -44,6 +44,7 @@ func main() { //nolint:funlen redisKey = "go-website" pageTimeout = 15 genhash = false + mapcache = false ) fl := flag.NewFlagSet("Website", flag.ExitOnError) @@ -73,6 +74,8 @@ func main() { //nolint:funlen "If set to false, do not cache the page index")) logIfErr(envflag.Bool(fl, &genhash, "genhash", "INTERACTIVE_HASH_GEN", "If set to true, interactively generate a password hash")) + logIfErr(envflag.Bool(fl, &mapcache, "mapcache", "USE_MAP_CACHE", + "Instead of utilizing redis, utilize a map internally for caching")) _ = fl.Parse(os.Args[1:]) @@ -96,6 +99,10 @@ func main() { //nolint:funlen app = &App{} } + if mapcache { + app.mapCache = true + } + err = app.ReadAuth(authConfFn) if err != nil { logger.Println(err) @@ -134,7 +141,7 @@ func main() { //nolint:funlen os.Stderr.Write(b) } - page.Funcs["ClearRedis"] = app.ClearRedis + page.Funcs["ClearCache"] = app.ClearCache srv := &http.Server{ Handler: app.Handler(), -- cgit v1.2.3