Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task(AB#0000): Set Model level TTL #541

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DharmaPriya-V
Copy link

@DharmaPriya-V DharmaPriya-V commented May 16, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant