Better cache invalidation for comparing LC reports
Summary
Therefore we had to generate cache key
To invalidate cache we have Ci::CompareLicenseScanningReportsService#key
method. Part of the key is generated using SoftwareLicensePolicy#workaround_cache_key
def self.workaround_cache_key
pluck(:id, :approval_status).flatten
end
Reason we do this instead of rails cache_key
method is that SoftwareLicensePolicy
table doesn't have created_at
and updated_at
columns.
Improvements
Add created_at
and updated_at
columns to the model and leverage them in code when generating key for reactive cache
Risks
We might need to do background migration
Involved components
Ci::CompareLicenseScanningReportsService
SoftwareLicensePolicy
Implementation Plan
-
Add a migration to add timestamp columns to the software_license_policies
table. -
Replace the usage of the workaround_cache_key with cache_key.
Edited by Can Eldem