Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8903105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:47:07+00:00 2026-06-15T01:47:07+00:00

Context: I’m working on an analytics system for an ordering system. There are about

  • 0

Context: I’m working on an analytics system for an ordering system. There are about 100,000 orders per day and the analytics need to run for the last N (say, 100) days months. The relevant data fits in memory. After N days, all orders are evicted from the memory cache, with an entire day in the past being evicted. Orders can be created or updated.

  1. A traditional approach would use a ConcurrentHashMap<Date, Queue<Order>>. Every day, values for keys representing dates more than N days in the past will be deleted. But, of course, the whole point of using Guava is to avoid this. EDIT: changed Map to ConcurrentHashMap, see the end of the question for rationale.

  2. With Guava collections, a MultiMap <Date, Order> would be simpler. Eviction is similar, implemented explicitly.

  3. While the Cache implementation looks appealing (after all, I am implementing a Cache), I’m not sure about the eviction options. Eviction only happens once a day and its best initiated from outside the cache, I don’t want the cache to have to check the age of an order. I’m not even sure if the cache would use a MultiMap, which I think it’s a suitable data structure in this case.

Thus, my question is: is it possible to use a Cache that uses and exposes the semantics of a MultiMap and allows evictions controlled from outside itself, in particular with the rule I need (“delete all orders older than N days”) ?

As an important clarification, I’m not interested in a LoadingCache but I do need bulk loads (if the application needs to be restarted, the cache has to be populated, from the database, with the last N days of orders).

EDIT: Forgot to mention that the map needs to be concurrent, as orders come in they are evaluated live against the previous orders for the same customer or location etc.

EDIT2: Just stumbled over Guava issue 135. It looks like the MultiMap is not concurrent.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:47:08+00:00Added an answer on June 15, 2026 at 1:47 am

    I would use neither a Cache nor a Multimap here. While I like and use both of them, there’s not much to gain here.

    • You want to evict your entries manually, so the features of Cache don’t really get used here.
    • You’re considering ConcurrentHashMap<Date, Queue<Order>>, which is in a sense more powerful than a Multimap<Date, Order>.

    I’d use a Cache, if I thought about different eviction criteria and if I felt like losing any of its entries anytime1 is fine.

    You may find out that you need a ConcurrentMap<Date, Dequeue<Order>> or maybe ConcurrentMap<Date, YouOwnQueueFastSearchList<Order>> or whatever. This could probably be managed somehow by the Multimap, but IMHO it gets more complicated instead of simpler.

    I’d ask myself “what do I gain by using Cache or Multimap here?”. To me it looks like the plain old ConcurrentMap offers about everything you need.


    1 By no means I’m suggesting this would happen with Guava. On the opposite, without an eviction reason (capacity, expiration, …) it works just like a ConcurrentMap. It’s just that what you’ve described feels more like a Map rather than a Cache.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Context I'm currently reading about Clojure's implementation of monads: org.clojure/algo.monads Intuitively, reduce looks like
Context: I have been working on and off on an application which uses a
Context: I'm working on exercises in Software Foundations . Theorem neg_move : forall x
Context: I'm making a simple solar system simulation in c++/OpenGL. Research: I've tried searching
Context I need to build a formset to allow opening hours to be set
Context I'm working on a small web app to store photos. Photos are ordered
Context We have this application, using about 60 coding projects. We have several products
Context is C#,.Net framework. Is it the application that runs without any need to
Context: In an ASP.NET application, I need the behavior of the ItemTemplate / EditItemTemplate
Context: I'm working on Project Euler Problem 23 using Matlab in order to practice

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.