Coverage for app/venv/lib/python3.14/site-packages/weblate/utils/cache.py: 70%

10 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 07:15 +0000

1# Copyright © Michal Čihař <michal@weblate.org> 

2# 

3# SPDX-License-Identifier: GPL-3.0-or-later 

4 

5from __future__ import annotations 

6 

7import time 

8 

9from django.core.cache import cache, caches 

10from django_redis.cache import RedisCache 

11 

12 

13def is_redis_cache() -> bool: 

14 return isinstance(caches["default"], RedisCache) 

15 

16 

17def measure_cache_latency() -> float: 

18 start = time.monotonic() 

19 cache.get("celery_loaded") 

20 return round(1000 * (time.monotonic() - start))