Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

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.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
Cache proxy multithreading issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cache proxy multithreading issue

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

    Code:
            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?
Working...
X