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 6557907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:08:00+00:00 2026-05-25T13:08:00+00:00

I am trying to do a simple thing like store something in the cache

  • 0

I am trying to do a simple thing like store something in the cache and retrieve it next time if it exists. For some reason everything works fine for the first time, when called the second time, everything in the cache file is removed and the cache is created again. Here is my ehcache config file

<ehcache>
  <diskStore path="<TEMP_DIR_PATH>" />
  <defaultCache maxElementsInMemory="10000" eternal="true"
      timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true"
      maxElementsOnDisk="10000000" diskPersistent="true"
      diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" />
   <cache name="mycache" maxElementsInMemory="1" eternal="true"
       overflowToDisk="true" timeToIdleSeconds="300" timeToLiveSeconds="600"
       diskPersistent="true" diskExpiryThreadIntervalSeconds="1"
       memoryStoreEvictionPolicy="LFU"/>
</ehcache>

The code actually creates 2 files one named mycache.index and the other named mycache.data. The code to put the value in to cache is given below.

Cache cache = cacheManager.getCache("mycache");
Element myElement= new Element("KEY1","This will be stored in cache");
cache.put(myElement);

Could someone please point out where things are going wrong?

I wanted to use the same stored cache file everytime and create a new file only if the data file is not present.

  • 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-25T13:08:00+00:00Added an answer on May 25, 2026 at 1:08 pm

    You need to call cache.flush() or cache.dispose() to dump the pending data to disk.

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

Sidebar

Related Questions

I am trying something very simple, but for some reason it does not work.
I'm trying to do something simple to practice my Javascript (which I learned some
I am trying to do a seemingly simple thing, but having trouble accomplishing it.
I am trying to do a fairly simple thing in my WPF application, or
I'm trying to do what I think is a simple thing under Linux. I
I'm trying to do a simple update. I've done this kind of thing thousands
I'm trying to get this simple PowerShell script working, but I think something is
I'm trying to make a simple xml-editor for some basic but specific needs, the
Like most users, I'm simply trying to figure out a secure way to store
This is a simple question I think. I am trying to search for the

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.