Add some caching
This commit is contained in:
@@ -53,11 +53,13 @@ func ActionServe(c *cli.Context) error {
|
||||
|
||||
// Setup logging
|
||||
loggers := setupLoggers(cfg)
|
||||
loggers.rootLogger.Infow("Startin apiary", "version", apiary.FullVersion())
|
||||
|
||||
// Setup store
|
||||
var s store.LoginAttemptStore
|
||||
switch cfg.Store.Type {
|
||||
case "MEMORY", "memory":
|
||||
loggers.rootLogger.Debugw("Initializing store", "store_type", "memory")
|
||||
s = &store.MemoryStore{}
|
||||
case "POSTGRES", "postgres":
|
||||
pgStore, err := store.NewPostgresStore(cfg.Store.Postgres.DSN)
|
||||
@@ -67,7 +69,14 @@ func ActionServe(c *cli.Context) error {
|
||||
if err := pgStore.InitDB(); err != nil {
|
||||
return err
|
||||
}
|
||||
s = pgStore
|
||||
if cfg.Store.EnableCache {
|
||||
loggers.rootLogger.Debugw("Initializing store", "store_type", "cache-postgres")
|
||||
cachingStore := store.NewCachingStore(pgStore)
|
||||
s = cachingStore
|
||||
} else {
|
||||
loggers.rootLogger.Debugw("Initializing store", "store_type", "postgres")
|
||||
s = pgStore
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("Invalid store configured")
|
||||
}
|
||||
|
Reference in New Issue
Block a user