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

  • Home
  • SEARCH
  • 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 4085426
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:34:35+00:00 2026-05-20T18:34:35+00:00

I have a TableHandler which implements table loading / reloading logic. By table I

  • 0

I have a TableHandler which implements table loading / reloading logic. By table I mean the data I load from either disc or memory when a user request for it in the form of table object. If a new request arrives and the instance of table is in memory then I just loads the table from memory and don’t reloads it from disc. If the table I am looking for is not present in memory I just loads the table from disc. Now As my request are increasing a lot of tables are getting stored in memory so I want to release some tables automatically from memory after say 5 min which aren’t been excessed for a duration of 5 min. How can I implement it?
I have tablehandler class structure like this

final class TableHandler{

   /*
   Data struct for storing information required for management 
   of the loaded table    instances
   */

    final static class Tableinfo{

       /*
       Table instance.. and other things like table when 
       last modified and whether to referench the table 
       when a next request arrives.
       */

    }

    getTable(){someInternalTableHandler.getTable()}

    replacetable {someInternalTableHandler.replacetable()}

    //Handles loading/reloading logic.

    final static class someInternalTablehandler{

        getTable(){...}
        createTableInstance(){...}
        replaceTable{...}

    } 
}

How can I implement the above said logic into my code….??

  • 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-05-20T18:34:36+00:00Added an answer on May 20, 2026 at 6:34 pm

    You can use the Guava MapMaker to do this:
    http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/collect/MapMaker.html

    Map map = new MapMaker().expireAfterWrite(5, TimeUnit.MINUTES).makeMap();
    

    If you don’t want to hard code it to a time, you can use soft references for your values in the created map. This will cause your map’s values to be dropped if they are no longer referenced and the JVM is running out of memory.

    Rolling your own map that uses weak/soft references to clear itself isn’t too hard either. Take a look at ReferenceQueue, WeakReference, and SoftReference

    There are some projects that allow you to annotate a method with @Cache and all return values of that method will be cached and cleared when no longer referenced. http://code.google.com/p/tantalizing-eats/

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

Sidebar

Related Questions

Have a bunch of classes which I need to do serialize and deserialize from/to
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have you refactored from an ActiveRecord to a DataMapper pattern? What conditions prompted the
have a table that dynamically generates text boxes in run time. I want to
I have a script that appends some rows to a table. One of the
I have a login.jsp page which contains a login form. Once logged in the
i have a input tag which is non editable, but some times i need
Have you ever tried working with a XAML file which contains thousand tons of
Have just started using Google Chrome , and noticed in parts of our site,
Have you ever seen any of there error messages? -- SQL Server 2000 Could

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.