I've noticed that in the Get() method, a new getOpts structure is created every time getWithOpts() is called. This frequent allocation of objects may lead to increased GC overhead. Have you considered using sync.Pool to optimize the allocation and reduce the GC pressure?
Using a sync.Pool to store and reuse getOpts instances can help minimize the number of allocations and deallocations, which in turn can improve the performance of the cache, especially in high-concurrency scenarios.
Here's a rough example of how sync.Pool could be used:
Could you better explain how this might increase GC overhead? The getOpts value isn't a pointer nor is it being stored anywhere where GC might need to kick in.
Hi there,
I've noticed that in the Get() method, a new getOpts structure is created every time getWithOpts() is called. This frequent allocation of objects may lead to increased GC overhead. Have you considered using sync.Pool to optimize the allocation and reduce the GC pressure?
Using a sync.Pool to store and reuse getOpts instances can help minimize the number of allocations and deallocations, which in turn can improve the performance of the cache, especially in high-concurrency scenarios.
Here's a rough example of how sync.Pool could be used:
Please let me know your thoughts on this suggestion. I'd be happy to contribute a PR if you think it's a worthwhile optimization.
Thank you!