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.

OperationCache Behaviour
GET single configHGET → cache hit returns JSON; miss triggers serialize + HSET
GET config listHGETALL; if empty, serialize all processes and HMSET
Create/Update configInvalidate + re-set affected hash fields
Enable/DisableInvalidate + re-set
DELETE cacheFull 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.

ModelActions LoggedCategory IDs
Processcreated, updated, enabled, disabled, linked/unlinked subprocess, created/deleted linked instances, bulk operations594-595, 596-599, 718-724
SubProcesscreated, updated, enabled, disabled594-597
Questioncreated, updated, enabled, disabled594-597
LabFormcreated, updated, linked/unlinked process, revoked907-910, 928
QuestionValue (update)aoe value updates with diff962
AdditionalPatientInfobulk created values977
AdditionalPatientInfobulk updated values with diff978
AdditionalPatientInfoSettingsbulk created settings970
AdditionalPatientInfoSettingsenabled/disabled settings971
AdditionalPatientInfoSettingsset default settings972

Log messages include the acting user's name (labUserName from session).

On this page