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

Adding refreshThreshold Parameter to the wrap Function #606

Closed
eternasuno opened this issue Oct 27, 2023 · 3 comments
Closed

Adding refreshThreshold Parameter to the wrap Function #606

eternasuno opened this issue Oct 27, 2023 · 3 comments

Comments

@eternasuno
Copy link

The cache's TTL can vary significantly, for instance, between 5 minutes and 1 day. It's challenging to determine a single, unified refreshThreshold setting for all use cases. Therefore, adding a separate refreshThreshold parameter to the wrap function could be a valuable enhancement.

@jaredwray
Copy link
Owner

@eternasuno - can you give a couple examples of this use case?

@eternasuno
Copy link
Author

@eternasuno - can you give a couple examples of this use case?

For example, I cached an authentication token, which expires after 2 hours. Therefore, the refreshThreshold should be set to 0. On the one hand, I have some caches that need to update their expiration time, but they cannot do so when there is only a unified refreshThreshold.

lchenay added a commit to lchenay/node-cache-manager that referenced this issue Dec 29, 2023
@lchenay
Copy link
Contributor

lchenay commented Dec 29, 2023

+1 for this feature.

I have created a little WIP PR: #630

I think the need of refreshThreshold parameter is linked to what is the right usage of cache-manager.
If you have only 1 instance of cache, then finding global refreshThreshold value is hard. Some people may create 1 instance per type of cache ; and so using hard coded as default value ttl / refreshThreshold are not an issue in this case.

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

No branches or pull requests

3 participants