Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract urls_expire_after factory #1867

Merged
merged 1 commit into from
Mar 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions plextraktsync/util/Factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,24 @@ def server_config(self):
return server_config.get_server(server_name)

@cached_property
def session(self):
from requests_cache import CachedSession

if self.run_config.cache:
urls_expire_after = self.config.http_cache.urls_expire_after
else:
def urls_expire_after(self):
if not self.run_config.cache:
from requests_cache import DO_NOT_CACHE

urls_expire_after = {
return {
"*": DO_NOT_CACHE,
}

return self.config.http_cache.urls_expire_after

@cached_property
def session(self):
from requests_cache import CachedSession

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
Expand Down
Loading