Skip to content

Commit

Permalink
Extract urls_expire_after factory
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Mar 17, 2024
1 parent 89c1164 commit 890ab82
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions plextraktsync/util/Factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,23 @@ def server_config(self):
def session(self):
from requests_cache import CachedSession

if self.run_config.cache:
urls_expire_after = self.config.http_cache.urls_expire_after
else:
from requests_cache import DO_NOT_CACHE

urls_expire_after = {
"*": DO_NOT_CACHE,
}

return CachedSession(
cache_name=self.config.cache_path,
cache_control=True,
urls_expire_after=urls_expire_after,
urls_expire_after=self.urls_expire_after,
)

@cached_property
def urls_expire_after(self):
if self.run_config.cache:
return self.config.http_cache.urls_expire_after

from requests_cache import DO_NOT_CACHE

return {
"*": DO_NOT_CACHE,
}

@cached_property
def sync(self):
from plextraktsync.sync.Sync import Sync
Expand Down

0 comments on commit 890ab82

Please sign in to comment.