gcache 2.0.4__tar.gz → 2.1.0__tar.gz

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.
gcache-2.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Galileo Technologies Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,8 +1,9 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: gcache
3
- Version: 2.0.4
3
+ Version: 2.1.0
4
4
  Summary: Fine grained caching.
5
- License: MIT
5
+ License-Expression: MIT
6
+ License-File: LICENSE
6
7
  Author: Galileo Technologies Inc.
7
8
  Author-email: team@rungalileo.io
8
9
  Requires-Python: >=3.10
@@ -21,11 +22,11 @@ Classifier: Topic :: Software Development :: Libraries
21
22
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
23
  Classifier: Typing :: Typed
23
24
  Requires-Dist: cachetools (>=5.5.2)
24
- Requires-Dist: prometheus-client (>=0.24.1,<0.25.0)
25
+ Requires-Dist: prometheus-client (>=0.22.1,<1.0.0)
25
26
  Requires-Dist: pydantic (>=2.11.4,<3.0.0)
26
27
  Requires-Dist: redis (>=5.0.0)
27
28
  Requires-Dist: types-cachetools (>=6.2.0.20250827,<7.0.0.0)
28
- Requires-Dist: uvloop (>=0.22.1,<0.23.0)
29
+ Requires-Dist: uvloop (>=0.21.0,<1.0.0)
29
30
  Project-URL: Homepage, https://github.com/rungalileo/gcache
30
31
  Project-URL: Repository, https://github.com/rungalileo/gcache
31
32
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "gcache"
3
- version = "2.0.4"
3
+ version = "2.1.0"
4
4
  description = "Fine grained caching."
5
5
  authors = [{ name = "Galileo Technologies Inc.", email = "team@rungalileo.io" }]
6
6
  readme = "README.md"
@@ -31,11 +31,11 @@ repository = "https://github.com/rungalileo/gcache"
31
31
  [tool.poetry.dependencies]
32
32
  python = "^3.10"
33
33
  pydantic = "^2.11.4"
34
- prometheus-client = "^0.24.1"
34
+ prometheus-client = ">=0.22.1,<1.0.0"
35
35
  cachetools = ">=5.5.2"
36
36
  types-cachetools = "^6.2.0.20250827"
37
37
  redis = ">=5.0.0"
38
- uvloop = "^0.22.1"
38
+ uvloop = ">=0.21.0,<1.0.0"
39
39
 
40
40
 
41
41
  [tool.poetry.group.test.dependencies]
@@ -66,14 +66,20 @@ class CacheController(CacheWrapper):
66
66
  GCacheMetrics.REQUEST_COUNTER.labels(key.use_case, key.key_type, self.layer().name).inc()
67
67
 
68
68
  fallback_failed = False
69
+ fallback_succeeded = False
70
+ fallback_result: Any = None
69
71
 
70
72
  async def instrumented_fallback() -> Any:
71
73
  nonlocal fallback_failed
74
+ nonlocal fallback_result
75
+ nonlocal fallback_succeeded
72
76
  nonlocal fallback_time
73
77
  start_fallback = time.monotonic()
74
78
  GCacheMetrics.MISS_COUNTER.labels(key.use_case, key.key_type, self.layer().name).inc()
75
79
  try:
76
- return await fallback()
80
+ fallback_result = await fallback()
81
+ fallback_succeeded = True
82
+ return fallback_result
77
83
  except Exception:
78
84
  fallback_failed = True
79
85
  raise
@@ -94,9 +100,23 @@ class CacheController(CacheWrapper):
94
100
  type(e).__name__,
95
101
  fallback_failed,
96
102
  ).inc()
97
- if not fallback_failed:
98
- return await fallback()
99
- else:
103
+ if fallback_failed:
104
+ raise
105
+ if fallback_succeeded:
106
+ return fallback_result
107
+ try:
108
+ return await instrumented_fallback()
109
+ except Exception as fallback_error:
110
+ _GLOBAL_GCACHE_STATE.logger.error(
111
+ f"Error in fallback after cache read failure: {fallback_error}", exc_info=True
112
+ )
113
+ GCacheMetrics.ERROR_COUNTER.labels(
114
+ key.use_case,
115
+ key.key_type,
116
+ self.layer().name,
117
+ type(fallback_error).__name__,
118
+ True,
119
+ ).inc()
100
120
  raise
101
121
  finally:
102
122
  GCacheMetrics.GET_TIMER.labels(key.use_case, key.key_type, self.layer().name).observe(
File without changes
File without changes
File without changes
File without changes
File without changes