[erlang-questions] How would you implement TTL for ETS based cache?

Dmitry Kolesnikov dmkolesnikov@REDACTED
Thu Mar 14 21:51:42 CET 2013


Hello Max,

Like, I've said that code is proto level. I have not brought it anywhere except my test env.
However, it is very simple and straight forward. This is nothing more then gen_server controlling ETS 
As part of immediate improvements, I'd like to highlite
 - change of cache i/o (they are masked behind gen_server)
 - make a notification during eviction process
 
You are right, it is missing the documentation but it would be possible to add it.
I am preparing to use it for one of my solution where I need multiple eviction policy including TTL & memory threshold  

- Dmitry 


On Mar 14, 2013, at 4:38 PM, Max Bourinov <bourinov@REDACTED> wrote:

> Hi Dmitry,
> 
> Thank you for sharing your code. Do you plan to add some docs to it?
> 
> Do you use this project? At which state it is now?
> 
> Best regards,
> Max
> 
> 
> 
> On Thu, Mar 14, 2013 at 3:29 PM, Dmitry Kolesnikov <dmkolesnikov@REDACTED> wrote:
> Hello Max,
> 
> I have been experimenting with similar approach. The main idea was to keep a two ETS based indexes. The first one it key-value map, second is expire-key map. Second index allows you to handle eviction. You have a process that evict a items when they are expired. 
> 
> I did a quick proto but never had opportunity to evolve it further. 
> https://github.com/fogfish/cache
> 
> It would be excellent to get community comments on it.
> 
> 
> Best Regards,
> Dmitry >-|-|-*>
> 
> 
> On 14.3.2013, at 16.15, Max Bourinov <bourinov@REDACTED> wrote:
> 
>> Hi Erlangers,
>> 
>> How would you implement TTL with callback for ETS based cache?
>> 
>> I want when TTL expires callback is triggered and cached value goes to DB.
>> 
>> For key I use 32 byte long binary(), value is not bigger than 8 KB. 
>> 
>> Any suggestions?
>> 
>> p.s. elang:send_after/3 is a most brutal approach, but how would it be when cache is under load?
>> 
>> Best regards,
>> Max
>> 
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130314/0c5d14ae/attachment.htm>


More information about the erlang-questions mailing list