lsrestclient 3.3.1__py3-none-any.whl → 3.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
lsrestclient/client.py CHANGED
@@ -77,6 +77,8 @@ class LsRestClient(object):
77
77
  ignore_bearer_context: bool = False,
78
78
  cache: bool = False,
79
79
  cache_backend: LsRestClientBackendEnum = LsRestClientBackendEnum.sqlite,
80
+ cache_control: bool = True,
81
+ stale_while_revalidate: bool = True,
80
82
  ) -> None:
81
83
  """Class representing a REST client for JSON API."""
82
84
  if cache:
@@ -93,7 +95,12 @@ class LsRestClient(object):
93
95
  else:
94
96
  backend = SQLiteCache(f".cache/{name}")
95
97
 
96
- self._session = CachedSession(backend=backend, cache_control=True, filter_fn=self.cache_filter)
98
+ self._session = CachedSession(
99
+ backend=backend,
100
+ cache_control=cache_control,
101
+ filter_fn=self.cache_filter,
102
+ stale_while_revalidate=stale_while_revalidate,
103
+ )
97
104
 
98
105
  else:
99
106
  self._session = Session()
@@ -113,6 +120,11 @@ class LsRestClient(object):
113
120
  super().__init__()
114
121
  self._clients[name] = self
115
122
 
123
+ def clear_cache(self):
124
+ if not isinstance(self._session, CachedSession):
125
+ raise Exception("Cache not enabled.")
126
+ self._session.cache.clear()
127
+
116
128
  def cache_filter(self, response: Response) -> bool:
117
129
  settings = LsRestClientSettings()
118
130
  cache_control = response.headers.get("Cache-Control")
@@ -1,12 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lsrestclient
3
- Version: 3.3.1
3
+ Version: 3.4.0
4
4
  Summary: REST Api Client
5
5
  Author: mba
6
6
  Author-email: bartel@electronic-shop.lu
7
7
  Requires-Python: >=3.12,<4.0
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Provides-Extra: redis
10
+ Requires-Dist: fastapi-lsoft (>=1.2.0,<2.0.0)
10
11
  Requires-Dist: lsjsonclasses (>=2.0.1,<3.0.0)
11
12
  Requires-Dist: pydantic (>=2.11.7,<3.0.0)
12
13
  Requires-Dist: pydantic-settings (>=2.10.1,<3.0.0)
@@ -1,6 +1,6 @@
1
1
  lsrestclient/__init__.py,sha256=lI62SHmG0m-iukB5UEwdN5dO4cKnDasOt-TmR1rgaWI,72
2
2
  lsrestclient/auth.py,sha256=IC6niEht-xB_wC7da0HIeM05Ha785qhls-Q39P6dMHQ,467
3
- lsrestclient/client.py,sha256=Nd3QQ9g0EOhcemJRnuGXpY_eeho5Cn2JNRMmGVeIDpc,13435
3
+ lsrestclient/client.py,sha256=oBrzclu96e9hAMXLcJBAOfKb0qsy55TVvOZ6S48XTas,13822
4
4
  lsrestclient/contexts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  lsrestclient/contexts/bearer_token.py,sha256=GZZOzAI2Ng_9DvFCbhv1Wwb8wJ1AYCca3fQeNtt2NaU,753
6
6
  lsrestclient/exceptions.py,sha256=exJd1BfygNkkAqekmWepVXvXlMiOInVzPRnq7TmPURs,2149
@@ -9,7 +9,7 @@ lsrestclient/lsfastapi.py,sha256=Hn-PgV8RKifa0BbNZzbuK-FCVbJpFmUIpItxZbivd0A,108
9
9
  lsrestclient/mock.py,sha256=Ya12F0t5sXHTSt-X4jDDj5ILJx6y6QaBAMXutQMsIRI,1376
10
10
  lsrestclient/response.py,sha256=4DYeN9e7phcrbm0QwwQS7uBI-sTDq7bKkP28BRWCzqA,2704
11
11
  lsrestclient/settings.py,sha256=qRhQYFCOA8sKhejrd7r47Q4Vo6mQjLbXko7jv3_889A,350
12
- lsrestclient-3.3.1.dist-info/METADATA,sha256=x_Ca7Z50UAD3AN5V_hldTVtxGDvfRSKZlVitlJasZmw,6816
13
- lsrestclient-3.3.1.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
14
- lsrestclient-3.3.1.dist-info/entry_points.txt,sha256=7lN1XN3lq5Jv5PlpOdIlFrLlFlwzE5MaEWSgMhKASOM,47
15
- lsrestclient-3.3.1.dist-info/RECORD,,
12
+ lsrestclient-3.4.0.dist-info/METADATA,sha256=g4m0vVv1vbO0oSFjmXQwr4yWGyX-Ghb7oj8gdxMdoU8,6862
13
+ lsrestclient-3.4.0.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
14
+ lsrestclient-3.4.0.dist-info/entry_points.txt,sha256=7lN1XN3lq5Jv5PlpOdIlFrLlFlwzE5MaEWSgMhKASOM,47
15
+ lsrestclient-3.4.0.dist-info/RECORD,,