LFU Cache Out-of-the-box

I have to build a LFU cache and we are thinking of using Couchbase for the same. I understand that couchbase evicts entries from RAM using LFU algorithm and it moves LFU entries form RAM to the disk. But that doesn’t give me true LFU, it will start throwing errors if size of my data becomes more than available disk. I would like LFU entries to evict automatically from the disk as well. Is there something available out-of-the-box in Couchbase.

To put it in different words. I don’t want 100% of my data in couchbase as I have another persistent data store. I want only most frequently accessed data in couchbase.
Thanks in advance.

Hi @amitsharma10,

so if you use Couchbase bucket it will always persist data to disk in addition to keeping it in RAM. If your data grows larger than you have memory available it will eject LRU data out of ram (or everything if you use full eviction in 3.0+). If you access it again it moves it back into RAM.

We also provide TTL functionality where you can provide an expiry time when you store the document, but it will then also be removed if it is still in RAM. Since you have another persistent data store what could work is that you define a reasonable TTL and every time you access it this TTL is refreshed. This would automatically purge inactive items out of couchbase, but of course also from RAM. Depending on your requirements this might work well.

The other option would be to use memcached buckets, but then you get no persistence at all.