Config: Add option to change default session cache duration #808 #3943

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2024-04-17 08:26:35 +02:00
parent e25626cd0c
commit 0134c68d2c
9 changed files with 60 additions and 21 deletions

View File

@@ -2,6 +2,7 @@ package config
import (
"regexp"
"time"
"golang.org/x/crypto/bcrypt"
@@ -160,6 +161,24 @@ func (c *Config) SessionTimeout() int64 {
return c.options.SessionTimeout
}
// SessionCache returns the default session cache duration in seconds.
func (c *Config) SessionCache() int64 {
if c.options.SessionCache == 0 {
return DefaultSessionCache
} else if c.options.SessionCache < 60 {
return 60
} else if c.options.SessionCache > 3600 {
return 3600
}
return c.options.SessionCache
}
// SessionCacheDuration returns the default session cache duration.
func (c *Config) SessionCacheDuration() time.Duration {
return time.Duration(c.SessionCache()) * time.Second
}
// DownloadToken returns the DOWNLOAD api token (you can optionally use a static value for permanent caching).
func (c *Config) DownloadToken() string {
if c.Public() {