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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:31:24+00:00 2026-05-31T07:31:24+00:00

Does anybody know how the default key generation for Ehcache works? If I have

  • 0

Does anybody know how the default key generation for Ehcache works? If I have the following method:

@Cacheable(cacheName = CACHE_KEY) // CACHE_KEY is static final field.
public List<DataObject> list(
    int firstRecord, int maxRecords, int pageSize, FilterObject filter) {
    ....
}

where FilterObject is a custom POJO, what should I expect to be the actual cache key?

What I am observing is when using different FilterObject instances and not changing the other arguments of my method call, it always produces the same result – the first call’s result is cached and returned.

Probably it is the FilterObject POJO which causes the behaviour – I suppose it is either some serialization, or .toString() issue, because I haven’t overridden the relevant methods.

Still I was unable to find exact information on how the cache key for such method is being formed both in Ehcache’s website and in the @Cacheable annotation documentation.
I’d appreciate any information and recommendations on this topic.

  • 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-31T07:31:25+00:00Added an answer on May 31, 2026 at 7:31 am

    This is the default key generator

    public class DefaultKeyGenerator implements KeyGenerator {
    
    public static final int NO_PARAM_KEY = 0;
    public static final int NULL_PARAM_KEY = 53;
    
    public Object generate(Object target, Method method, Object... params) {
        if (params.length == 1) {
            return (params[0] == null ? NULL_PARAM_KEY : params[0]);
        }
        if (params.length == 0) {
            return NO_PARAM_KEY;
        }
        int hashCode = 17;
        for (Object object : params) {
            hashCode = 31 * hashCode + (object == null ? NULL_PARAM_KEY : object.hashCode());
        }
        return Integer.valueOf(hashCode);
    }
    
    }
    

    As you can see, it combines the hash-codes of each method parameter.

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

Sidebar

Related Questions

Does anybody know how to disable the default CKEditor behavior that changes the RichCombo
Does anybody know of a method for creating custom Performance Counters using ordinary unmanaged
Does anybody know of a method for specializing a template depending on whether a
Does anybody know what will happen to Knockout's default template engine now when jQuery.tmpl
Does anybody know how I can set the number of default facets in solr?
Does anybody know if netbeans by default uses the hotspot server vm? I'm trying
Does anybody know where an iOS app can see the default headers that NSUrlRequest
Just wondering does anybody know the default location for .mdmp/.hdmp files on Windows Server
does anybody know a way to show that default alert like Your application wants
Does anybody know any good resources for learning how to program CIL with in-depth

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.