mailgun / groupcache

Clone of golang/groupcache with TTL and Item Removal support
Apache License 2.0
484 stars 72 forks source link

Move global state to explicit var to allow deallocation? #66

Open udhos opened 8 months ago

udhos commented 8 months ago

Hi,

I have a use case for, while not restarting the application, bringing down groupcache allocated resources (let the GC release them), then recreate those resources with new configurations.

I see the global state is the obvious roadblock for that scenario.

So I started to sketch a change to allow recreation of groupcache resources. I am keeping existing APIs unchanged and adding some alternative APIs with support for an extra argument for explicit state ("workspace") provided by the caller. Hence the caller would be able to drop references to workspace in order to allow the garbage collector to get rid of its resources.

Draft PR: https://github.com/mailgun/groupcache/pull/65

What do you think? Would this be generally useful for a wider audience?

Cheers, Everton