jellydator / ttlcache

An in-memory cache with item expiration and generics
MIT License
883 stars 115 forks source link

SetUnsafe like IsExpiredUnsafe #127

Open osr00 opened 3 months ago

osr00 commented 3 months ago

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 commented 3 months ago

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

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

osr00 commented 3 months ago

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?