ttlcache icon indicating copy to clipboard operation
ttlcache copied to clipboard

SetUnsafe like IsExpiredUnsafe

Open osr00 opened this issue 1 year ago • 2 comments

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.

osr00 avatar Mar 11 '24 15:03 osr00

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?

swithek avatar Mar 13 '24 07:03 swithek

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?

osr00 avatar Mar 13 '24 12:03 osr00