add cache_timeout option

controls how old the Jellyfin user cache can be before refetching. defaults to 30 minutes.
This commit is contained in:
Harvey Tindall
2020-11-02 23:26:46 +00:00
parent d4a92adc65
commit 8e45ecb214
5 changed files with 15 additions and 5 deletions
+2 -2
View File
@@ -48,7 +48,7 @@ type Jellyfin struct {
}
// NewJellyfin returns a new Jellyfin object.
func NewJellyfin(server, client, version, device, deviceID string, timeoutHandler common.TimeoutHandler) (*Jellyfin, error) {
func NewJellyfin(server, client, version, device, deviceID string, timeoutHandler common.TimeoutHandler, cacheTimeout int) (*Jellyfin, error) {
jf := &Jellyfin{}
jf.Server = server
jf.client = client
@@ -78,7 +78,7 @@ func NewJellyfin(server, client, version, device, deviceID string, timeoutHandle
data, _ := ioutil.ReadAll(resp.Body)
json.Unmarshal(data, &jf.ServerInfo)
}
jf.cacheLength = 30
jf.cacheLength = cacheTimeout
jf.CacheExpiry = time.Now()
return jf, nil
}