Best way to implement a simple cache

Thijs thijsterlouw@REDACTED
Thu Nov 12 05:50:33 CET 2009


> > Why wouldn't an ETS be good for this?

I think ETS is better for 'get' operations than going through a
managing process:

A process-approach suffers from sequential access. This might not be
so important since lookups can be very fast, but worth keeping in
mind. A public/protected ETS table with one owning manager-process
doesn't suffer from this problem. If you want to do LRU-eviction
strategy or something like that, you could let your 'set' operations
still go through the gen_server (and evict if required) and 'get'
operations go directly to the ETS table.

Or use Cherly as noted above :)





More information about the erlang-questions mailing list