allegro / bigcache

Efficient cache for gigabytes of data written in Go.
http://allegro.tech/2016/03/writing-fast-cache-service-in-go.html
Apache License 2.0
7.38k stars 590 forks source link

Add multi-level cache design #375

Open vearne opened 10 months ago

vearne commented 10 months ago

Like ehcache,Some hotspot key-values reside directly in the heap, while other key-values are stored in the original way.

janisz commented 10 months ago

actually we keep values in the heap. Could you elaborate?

vearne commented 10 months ago

I have a scenario where I want to store 10,000,000 key-value in the local cache, but this value is a relatively complex object. According to the current logic of bigcache, the value will be serialized into bytes for storage, and then actually, when I want to use Sometimes, I need to deserialize value from bytes into objects. Since this service is a high-frequency request, value will be serialized into objects repeatedly, causing a lot of CPU consumption. So I wonder if I can add a cache and store high-frequency key-values directly in the map (for example, using segmentation locks). This can reduce the cost of deserializing values from bytes into objects.