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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:03:26+00:00 2026-05-24T17:03:26+00:00

I’m trying to do a simple test with ehcache – put an element into

  • 0

I’m trying to do a simple test with ehcache – put an element into the cache, flush and shutdown the cache. Then reload all the beans with spring (also initializes cachemanager). Do a cache.get and retrieve previously written values.

EhCache Element’s value is a some serializable class called DOM which comprises a field ConcurrentHasMap

I create 3 DOM instances: d1, d2, d3
d1 (has a map with 3 values: t1, t2, t3)
d2 (has a map with 2 values: x1, x2)
d3 (has a map with 2 values: s1, s2)

I call:

cachemanager and cache are created with spring
cache.put(new Element(1,d1))
cache.put(new Element(2,d2))
cache.put(new Element(3,d3))
cache.flush();
cacheManager.shutdown();
cache = null
cacheManager = null

I call to load spring application context (which creates cacheManager and cache)

I call:

actualD1 = cache.get(1)
actualD2 = cache.get(2)
actualD3 = cache.get(3)

I receive the DOM objects into the actualD1, actualD2 and actualD3 variables
But the problem is that now each of them has only one value

actualD1 (has a map with 1 value: t1)
actualD2 (has a map with 1 value: x1)
actualD3 (has a map with 1 value: s1)

What could be the problem!???

Here is my ehcache.xml file:

<defaultCache
       maxElementsInMemory="1000000"
       eternal="false"
       diskSpoolBufferSizeMB="100"
       overflowToDisk="true"
       clearOnFlush="false"
       copyOnRead="false"
       copyOnWrite="false"
       diskExpiryThreadIntervalSeconds="300"
       diskPersistent="true">
</defaultCache>

Here is how I create a cacheManager (this method is called in startup from spring)

protected def checkAndCreateCacheManagerIfNeeded() =
{
    if (cacheManager == null)
    {
        synchronized
        {
            if (cacheManager == null)
            {
                cacheManager = CacheManager.create(ehCacheConfigFile);
            }
        }
    };
};

The following code creates the cache:

protected def getOrCreateCache(cacheName : String) =
{
    checkAndCreateCacheManagerIfNeeded();
    var cache = cacheManager.getEhcache(cacheName);
    if (cache == null)
    {
        cacheManager.synchronized
        {
            cache = cacheManager.getEhcache(cacheName);
            if (cache == null)
            {
                cache = cacheManager.addCacheIfAbsent(cacheName);
            }
        }
    };
    cache;
};
  • 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-24T17:03:26+00:00Added an answer on May 24, 2026 at 5:03 pm

    The problem was adding t1, t2, t3 to d1 without putting the updated d1 to the cache. After each addition of the value to map. One must add the call:

    cache.put(d1Element)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am currently running into a problem where an element is coming back from
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.