mirror of
https://github.com/element-hq/synapse.git
synced 2025-09-17 11:05:10 +02:00
Refactor cache metrics to be homeserver-scoped (#18604)
(add `server_name` label to cache metrics). Part of https://github.com/element-hq/synapse/issues/18592
This commit is contained in:
@@ -33,7 +33,10 @@ class ExpiringCacheTestCase(unittest.HomeserverTestCase):
|
||||
def test_get_set(self) -> None:
|
||||
clock = MockClock()
|
||||
cache: ExpiringCache[str, str] = ExpiringCache(
|
||||
"test", cast(Clock, clock), max_len=1
|
||||
cache_name="test",
|
||||
server_name="testserver",
|
||||
clock=cast(Clock, clock),
|
||||
max_len=1,
|
||||
)
|
||||
|
||||
cache["key"] = "value"
|
||||
@@ -43,7 +46,10 @@ class ExpiringCacheTestCase(unittest.HomeserverTestCase):
|
||||
def test_eviction(self) -> None:
|
||||
clock = MockClock()
|
||||
cache: ExpiringCache[str, str] = ExpiringCache(
|
||||
"test", cast(Clock, clock), max_len=2
|
||||
cache_name="test",
|
||||
server_name="testserver",
|
||||
clock=cast(Clock, clock),
|
||||
max_len=2,
|
||||
)
|
||||
|
||||
cache["key"] = "value"
|
||||
@@ -59,7 +65,11 @@ class ExpiringCacheTestCase(unittest.HomeserverTestCase):
|
||||
def test_iterable_eviction(self) -> None:
|
||||
clock = MockClock()
|
||||
cache: ExpiringCache[str, List[int]] = ExpiringCache(
|
||||
"test", cast(Clock, clock), max_len=5, iterable=True
|
||||
cache_name="test",
|
||||
server_name="testserver",
|
||||
clock=cast(Clock, clock),
|
||||
max_len=5,
|
||||
iterable=True,
|
||||
)
|
||||
|
||||
cache["key"] = [1]
|
||||
@@ -79,7 +89,10 @@ class ExpiringCacheTestCase(unittest.HomeserverTestCase):
|
||||
def test_time_eviction(self) -> None:
|
||||
clock = MockClock()
|
||||
cache: ExpiringCache[str, int] = ExpiringCache(
|
||||
"test", cast(Clock, clock), expiry_ms=1000
|
||||
cache_name="test",
|
||||
server_name="testserver",
|
||||
clock=cast(Clock, clock),
|
||||
expiry_ms=1000,
|
||||
)
|
||||
|
||||
cache["key"] = 1
|
||||
|
||||
Reference in New Issue
Block a user