Announcement Announcement Module

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions ( project, this forum has been decommissioned in favour of Spring Extensions one at:

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Costin Leau
SpringSource - Spring Training, Consulting, and Support - "From the Source"
See more
See less
Cache proxy multithreading issue Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cache proxy multithreading issue

    Snippet from org.springmodules.cache.interceptor.caching.Abstra ctCachingInterceptor

            public final Object invoke(MethodInvocation mi) throws Throwable {
                    Method method = mi.getMethod();
                    if (!CachingUtils.isCacheable(method))
                            return methodNotCacheable(mi, method);
                    CachingModel model = model(mi);
                    if (model == null) return noModelFound(mi, method);
                    Serializable key = keyGenerator.generateKey(mi);
                    Object cached = cache.getFromCache(key, model);
                    if (null == cached) return cachedValueFromSource(mi, key, model);
                    return unmaskNull(cached);
    Since cachedValueFromSource just goes ahead and invokes the method, under high load and with a slow underlying data layer there is a high probablilty that several threads will begin to load the missing data simultaneously, which is a waste of resources.

    I was thinking about rewriting this a little, but on the other hand that would be just duplicating logic that is already present in several of the cache implementations hidden behind CacheProviderFacade. Any thoughts?