protected boolean remove()

in commons-jcs3-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCache.java [1061:1110]


    protected boolean remove(final K key, final boolean localOnly)
    {
        removeCount.incrementAndGet();

        boolean removed = false;

        try
        {
            removed = memCache.remove(key);
        }
        catch (final IOException e)
        {
            log.error(e);
        }

        // Removes from all auxiliary caches.
        for (final ICache<K, V> aux : auxCaches)
        {
            if (aux == null)
            {
                continue;
            }

            final CacheType cacheType = aux.getCacheType();

            // for now let laterals call remote remove but not vice versa
            if (localOnly && (cacheType == CacheType.REMOTE_CACHE || cacheType == CacheType.LATERAL_CACHE))
            {
                continue;
            }
            try
            {
                log.debug("Removing {0} from cacheType {1}", key, cacheType);

                final boolean b = aux.remove(key);

                // Don't take the remote removal into account.
                if (!removed && cacheType != CacheType.REMOTE_CACHE)
                {
                    removed = b;
                }
            }
            catch (final IOException ex)
            {
                log.error("Failure removing from aux", ex);
            }
        }

        return removed;
    }