Find messages from certain key till certain key while being able to remove stale keys.

Posted by Alfred on Stack Overflow See other posts from Stack Overflow or by Alfred
Published on 2010-05-13T03:30:23Z Indexed on 2010/05/13 4:04 UTC
Read the original article Hit count: 172

My problem

Let's say I add messages to some sort of datastructure:

1. "dude"
2. "where"
3. "is"
4. "my"
5. "car"

Asking for messages from index[4,5] should return: "my","car".

Next let's assume that after a while I would like to purge old messages because they aren't useful anymore and I want to save memory. Let's say at time x messages[1-3] became stale. I assume that it would be most efficient to just do the deletion once every x seconds. Next my datastructure should contain:

4. "my"
5. "car"

My solution?

I was thinking of using a concurrentskiplistset or concurrentskiplist map. Also I was thinking of deleting the old messages from inside a newSingleThreadScheduledExecutor. I would like to know how you would implement(efficiently/thread-safe) this or maybe use a library?

© Stack Overflow or respective owner

Related posts about java

Related posts about concurrency