[erlang-questions] Optimal way to restrict a ram_copies table to N entries

Joel Reymont joelr1@REDACTED
Thu Jun 28 00:33:57 CEST 2007

I just love answering my own questions :-).

I think the optimal solution is to use ram_copies + ordered_set. The  
size of the table can be found out with mnesia:table_info/2 and if  
erlang:now() is used as a timestamp then the beginning or the end of  
the queue can be found with mnesia:first or mnesia:last.

I think the first item inserted can be found out with mnesia:first  
even on a set table. The only issue I can think of is erlang:now()  
differences among all the nodes.

Any flaws in my logic?

On Jun 27, 2007, at 10:45 AM, Joel Reymont wrote:

> Suppose I'm trying to use a ram_copies table as a cache and need to  
> come up with a cache eviction strategy. I would like to push the  
> oldest entry out upon inserting a new one once the ram_copies table  
> is full (N items).
> What's the best (quickest) way of doing this?
http://topdog.cc      - EasyLanguage to C# compiler
http://wagerlabs.com  - Blog

More information about the erlang-questions mailing list