task(AB#0000): Set Model level TTL #541
Open
+11
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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