clearAll() of LRU Cache!!!

All
2004-07-20
2013-03-22
  • Bipin Velkur

    Bipin Velkur - 2004-07-20

    Don't know if this project is still alive but here goes:
    The Clearall method of the LRUCache is

    <code>
      public void clearAll()
      {
        if(log.isDebugEnabled())
          log.debug("Purged " + cacheId + " cache.");

        cache = Collections.synchronizedMap(new LRUMap(size));
      }
    </code>

    This is not taking care of the map memberfield and also any listeners which were set on it. We need to change this to:

    <code>
      public void clearAll()
      {
        if(log.isDebugEnabled())
          log.debug("Purged " + cacheId + " cache.");

        map.clear();
      }
    </code>

    --Bipin

     
    • Bipin Velkur

      Bipin Velkur - 2004-07-20

      Ooops and I forgot to ask...

      shouldn't clearAll() be synchronized..

      --Bipin

       
    • Jonathan Taub

      Jonathan Taub - 2005-11-30

      I just wrote a piece of code that flushes the LRU cache by calling clearAll. It doesn't do anything.
      It that related to your posting (the map.clear() bug)?

      Are there any elegant workarounds?
      (iterating through the entire cache and clearing each element individually is considered elegant).

       
    • Jonathan Taub

      Jonathan Taub - 2005-11-30

      When I do the "clearAll" call, it works only on one VM. Other VMs do not clear the cache.
      However, when clearing a single element from the cache, other VMs get the change.

      So this is clearly not a networking issue.

       
    • Fernando Martins

      I've been experimenting/debugging this issue, and have noticed that when one JVM sends a CacheNotification with a key "(ALL)" (MultiCacheManager.CLEAR_ALL) the second JVM will receive this CacheNotification and execute the method receiveNotification on MultiCacheManager.
      And there the code is + - like this:
      (...)
      if (notification.getKey() == CLEAR_ALL) {
           cache.doClearAll();
      } else {
           cache.doClear(notification.getKey());
      }
      (...)

      So being CLEAR_ALL a String with value "(ALL)", the first condition will only be true if both are the same object on this JVM, which is not the case I think.
      So should the `if` be rather something like:
      if (CLEAR_ALL.equals(notification.getKey())) ?

      Can John Watkinson or one of the active developers clarify this please?

      Thanks
      Fernando Martins

       
    • Coder

      Coder - 2006-02-20

      This is a swarmcache bug I also ran into.

      You should patch it to use .equals()

      I think patch 1048007 (see patches in swarmcache project page) fixes this.

      Too bad swarmcache seems not to be maintained any more, it needs an RC3 release bad.

      --Coder

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks