Menu

#83 implement a concurrent version MruCacheStorage

open
nobody
None
5
2012-02-26
2012-02-26
Anonymous
No

Discussion

  • Dániel Dékány

    As far as I know (I'm not the author of that code), it's pretty much designed for many-thread access. What exactly is the issue?

     
  • Anonymous

    Anonymous - 2012-02-26

    MruCacheStorage implements CacheStorage
    SoftCacheStorage implements ConcurrentCacheStorage
    StrongCacheStorage implements ConcurrentCacheStorage

    MruCacheStorage is not concurrent,it will synchronize threads

    in TemplateCache:

    CachedTemplate cachedTemplate;
    if(isStorageConcurrent) { cachedTemplate = (CachedTemplate)storage.get(tk); }
    else {
    synchronized(storage) { cachedTemplate = (CachedTemplate)storage.get(tk); }
    }

     

    Last edit: Anonymous 2017-06-17
  • Dániel Dékány

    Sure. A CacheStorage that doesn't mark itself as thread-safe must be synchronized by the called. Those who do mark themselves as thread-safe do the synchronization themselves, but internally, somewhere, they will still use synchronized.

    So the question is the synchronization of MruCacheStorage a bottleneck in your app? I mean, those synchronized operations should complete really quick. They don't do anything heavy, like loading and parsing templates.

     
  • Dániel Dékány

    I meant: A CacheStorage that doesn't mark itself as thread-safe must be
    synchronized by the calleR.

     
  • Nobody/Anonymous

    MruCacheStorage is thread-safe also,but it's not concurrent (using java.util.concurrent) like SoftCacheStorage

     
  • Nobody/Anonymous

    In large scale application,it could be a bottleneck,if you can keep backward compatible and boost performance,why not?

     
  • Dániel Dékány

    As far as I don't see that it's a bottleneck in reality (and I doubt that it can be), there are much better places to invest developer time. Resources for developing FreeMarker are rather sparse. I would close this issue, if there's nothing more to it.

     

Log in to post a comment.