@CacheResult in combination with default interface method call

63 Views Asked by At

I have a JavaEE WebApp using jCache abstraction. Given I have an interface like this:

public interface Service {

    default ReturnObject getReturnObject(String userId) {
        return getReturnObject(userId, null);
    }

    ReturnObject getReturnObject(String userId, String customerId);

}

And its implementation as follows:

public class ServiceImpl {

    @Override
    @CacheResult(cacheName = CACHE_NAME, cacheKeyGenerator = DefaultObjectsCacheKeyGenerator.class)
    public ReturnObject getReturnObject(@CacheKey String userId, @CacheKey String customerId) {
...

    }
}

Can I expect the caching functionality to work properly, i.e. when the default method is getting called with one argument, then the caching will kick in with null as the second half of the cache key? I'm worried about something similar to what happens in a Spring proxy where in-class method calls are not proxied and hence no caching/transactioning stuff happens.

Any clues?

0

There are 0 best solutions below