feat: implement caching for duty-related data and enhance performance
- Added a TTLCache class for in-memory caching of duty-related data, improving performance by reducing database queries. - Integrated caching into the group duty pin functionality, allowing for efficient retrieval of message text and next shift end times. - Introduced new methods to invalidate caches when relevant data changes, ensuring data consistency. - Created a new Alembic migration to add indexes on the duties table for improved query performance. - Updated tests to cover the new caching behavior and ensure proper functionality.
This commit is contained in:
@@ -403,6 +403,9 @@ def test_calendar_ical_ignores_unknown_query_params(
|
||||
"""Unknown query params (e.g. events=all) are ignored; response is duty-only."""
|
||||
from types import SimpleNamespace
|
||||
|
||||
from duty_teller.cache import ics_calendar_cache
|
||||
|
||||
ics_calendar_cache.invalidate(("personal_ics", 1))
|
||||
mock_user = SimpleNamespace(id=1, full_name="User A")
|
||||
mock_get_user.return_value = mock_user
|
||||
duty = SimpleNamespace(
|
||||
|
||||
Reference in New Issue
Block a user