karlseguin / ccache

A golang LRU Cache for high concurrency
MIT License
1.28k stars 119 forks source link

Nice software. It's great! #18

Closed unisqu closed 5 years ago

unisqu commented 5 years ago

I'm using it but can you help save memory / garbage collection time by looking into this cache below? https://github.com/coocood/freecache

I hope it can be optimally used like freecache without a lot of GC happening. How does ccache compared with it? I will be using ccache frequently.

karlseguin commented 5 years ago

I only looked briefly at Freecache, but they are so different, they can't really be compared. From what I can tell, Freecache only accepts byte[] values. So if you want to store structs, you'll be constantly marshaling and unmarshaling them which may or may not be a big performance hit depending on what you're doing.

Ccache behaves more like a concurrent map with item expiry via an LRU.

It's a little bloated with features like Tracking and LayeredCache. This adds complexity to the library and a little clutter to the actual runtime performance.

You'd really need to benchmark them for your specific case, but I feel like they're so different that one will work for you and the other won't. Essentially, either you're only caching byte arrays (in which case, use Freecache) or you aren't.

unisqu commented 5 years ago

Thanks for the explanation. What do you use ccache for personally? http caching? (because of the layered cache feature I assume)

karlseguin commented 5 years ago

Well, I don't right much Go anymore. But at the time, yes, both the tracking feature and the layered cache came from HTTP caching.