[erlang-questions] Guidance to a cache mechanism

Dmitry Belyaev <>
Thu Nov 1 21:59:38 CET 2012


Garbage may fill the memory if consumer checks cache too seldom.

-- 
Dmitry Belyaev

----- Reply message -----
From: "Ian" <>
To: <>
Subject: [erlang-questions] Guidance to a cache mechanism
Date: Thu, Nov 1, 2012 20:16


Hi,

I'm not quite clear on what you want to do, but it appears that you want 
to discard messages if they are "too old", for some definition of too 
old, and you are proposing a combination of ETS and gen-server to do this.

Why not simply discard messages that are too old when you read them, and 
read the next? That, coupled with having no synchronous send/reads to 
stall your process, and you are golden.

Or have I missed something?

Ian

On 30/10/2012 11:08, Maruthavanan Subbarayan wrote:
> Hi,
>
> I have to develop a caching queue, which also should should after a 
> expiry time.
>
> I may have around 500+ messages which may come in a second. Each 
> message might contain 100-200 bytes.
>
> So I have designed the system like below.
>
> 1. Queue would be a gen server.
> 2. All messages which would come on same second would be stored in 
> state of the gen_server like a record {datetime(),[<list of messages>]}
> 3. When the time differs, I would insert the above record to ets table 
> and update the state of gen_server.
> 4. There would be a timer running timer:send_interval which would 
> message timeout the gen_server for every second, when this message is 
> received, then gen_server would delete the ets table according to 
> expiry configured.
>
> I was looking on some guidance to check if the above is fine and with 
> with stand the performance. I am foreseeing maximum expiry would be 
> around 60 minutes.
>
> Thanks,
> Marutha
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121102/f428ee7f/attachment.html>


More information about the erlang-questions mailing list