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/app.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/app.go')
| -rw-r--r-- | cmd/server/app.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cmd/server/app.go b/cmd/server/app.go index 9a00628..c694753 100644 --- a/cmd/server/app.go +++ b/cmd/server/app.go @@ -7,14 +7,17 @@ import ( "github.com/gomodule/redigo/redis" "gopkg.in/yaml.v3" + "riedstra.dev/mitch/go-website/mapcache" "riedstra.dev/mitch/go-website/page" ) var FeedPrefixDefault = ".feeds" type App struct { + mapCache bool redisPool *redis.Pool RedisKey string + cache *mapcache.Cache ReIndexPath string StaticDirectory string @@ -86,6 +89,16 @@ func loadConf(fn string) (*App, error) { return app, nil } +func (a *App) ClearCache() error { + if a.redisPool != nil { + return a.ClearRedis() + } + + a.cache.Clear() + + return nil +} + // ClearRedis is a little helper function that allows us to easily clear // the redis cache at runtime. func (a *App) ClearRedis() error { |
