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

SetUnsafe like IsExpiredUnsafe #127

Open
osr00 opened this issue Mar 11, 2024 · 2 comments
Open

SetUnsafe like IsExpiredUnsafe #127

osr00 opened this issue Mar 11, 2024 · 2 comments

Comments

@osr00
Copy link

osr00 commented Mar 11, 2024

ttlcache is really a great thing. We save the state in intervals and on exit of the application in a yaml file.

We reload the state of the cache values on restart of the application.

What we miss is a function SetUnsafe which can be used without mutex locking. So it would be much faster on bulk reload.

There is a set function but this is only locally and cannot be used globally.

@swithek
Copy link
Contributor

swithek commented Mar 13, 2024

This might be a good feature. We've got two options here:

  • Add SetBulk() which would insert/update multiple items. (Still unclear: should we return multiple items as a result?)
  • Add a WithInitialData() option that would be used when creating a cache.

I presume the first option would work better in your situation?

@osr00
Copy link
Author

osr00 commented Mar 13, 2024

For me both are good options.

For SetBulk just return an error or nil is sufficient for me. Maybe others see this differently

Because this will be used mainly on startup a WithInitialData option also is a good variant.

In the wild it will be rarely needed that a bulk update is needed after a start I guess. But who knows?

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

No branches or pull requests

2 participants