diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2023-01-07 13:31:23 -0500 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2023-01-07 13:31:23 -0500 |
| commit | ca33a035c779ae14fb6330c8801c75f49dd1bb79 (patch) | |
| tree | deaabaf15d6d91079a68f247e46070399e4343ee /cmd/server/main.go | |
| parent | 97dd660925434be537cd9a49a1d0c893b223e357 (diff) | |
| download | go-website-ca33a035c779ae14fb6330c8801c75f49dd1bb79.tar.gz go-website-ca33a035c779ae14fb6330c8801c75f49dd1bb79.tar.xz | |
Add an internal caching option. It performs quite well.v0.0.22
Also refactor and clean up most linter warnings.
Diffstat (limited to 'cmd/server/main.go')
| -rw-r--r-- | cmd/server/main.go | 9 |
1 files changed, 8 insertions, 1 deletions
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(), |
