task(AB#0000): Set Model level TTL
Currently in identity cache we can't able to set the model level TTL, it can be set only globally through the cache store. But in many cases for different models we might require different expiry time. Here while yielding the actual result to write to the cache we can set the expiry time.
In each model you can specify the constant value of expire_time, in the cache _value formation we can check if the constant is defined if so we can add the value with the key cache_expire to the result hash.
Class Model1 < ApplicationRecord
EXPIRE_CACHE = 24 * 60 * 60 # expiry of 1 day
end
This EXPIRE_CACHE will be retrieved and cached with this time for any record belonging to this model. All we have to do is to just set the cache constant value at the model level in the application
Glad to hear other thoughts as well