Caching & Logging
Redis caching strategy and activity logging for the Lab Forms module
👤 Ritu Kataria📅 Updated: Mar 13, 2026🏷️ feature
Caching & Logging
Caching Strategy
Redis Hash Cache
Key pattern: lab:{lab_id}:{form_type}:form:config
Each process's serialized config is stored as a hash field keyed by process.pk.
| Operation | Cache Behaviour |
|---|---|
| GET single config | HGET → cache hit returns JSON; miss triggers serialize + HSET |
| GET config list | HGETALL; if empty, serialize all processes and HMSET |
| Create/Update config | Invalidate + re-set affected hash fields |
| Enable/Disable | Invalidate + re-set |
| DELETE cache | Full DEL of the hash key |
The allow_individual_instance_caching = True flag on Process enables per-instance cache operations.
Cache is updated via update_cache_for_process() and update_lab_form_config_cache() which also refreshes the renderer config cache.
Activity Logging
Every significant action is logged via the ActivityLog system using category_id_mapper on each model.
| Model | Actions Logged | Category IDs |
|---|---|---|
| Process | created, updated, enabled, disabled, linked/unlinked subprocess, created/deleted linked instances, bulk operations | 594-595, 596-599, 718-724 |
| SubProcess | created, updated, enabled, disabled | 594-597 |
| Question | created, updated, enabled, disabled | 594-597 |
| LabForm | created, updated, linked/unlinked process, revoked | 907-910, 928 |
| QuestionValue (update) | aoe value updates with diff | 962 |
| AdditionalPatientInfo | bulk created values | 977 |
| AdditionalPatientInfo | bulk updated values with diff | 978 |
| AdditionalPatientInfoSettings | bulk created settings | 970 |
| AdditionalPatientInfoSettings | enabled/disabled settings | 971 |
| AdditionalPatientInfoSettings | set default settings | 972 |
Log messages include the acting user's name (labUserName from session).