0 Replies Latest reply on Mar 7, 2019 3:33 PM by snidely_whiplash

    How do I implement this eviction policy?

    snidely_whiplash

      If you have a message object like this:

       

      Message {

           String senderID;

           String messageText;

      }

       

      And your key could be like this.  Assume no sender can send more than 1 msg per second

       

      MessageKey {

           String senderID;

           ZonedDateTime sendingTime;

      }

       

      You could also add globally unique serial IDs to messages or keys when msgs are created if you want.

       

      How can I cache these so that I always have the most recent N messages from each sender? 

      Essentially a FIFO eviction policy so if  N=10 and some sender sends 10 messages those live in the cache until that sender sends his 11th message.  Then that sender's oldest message is evicted.

       

      Thanks!