@Override
    public synchronized void clear() {
        final Object[] keys = map.keySet().toArray();
        for (final Object key : keys) {
            remove(key);
        }

        // Now, reset all containers.
        map.clear();
        lastAccessedList.clear();
        lastAccessedList = new org.jivesoftware.util.LinkedList<>();
        ageList.clear();
        ageList = new org.jivesoftware.util.LinkedList<>();

        cacheSize = 0;
        cacheHits = 0;
        cacheMisses = 0;
    }
Create a new default cache and specify the maximum size of for the cache in
bytes, and the maximum lifetime of objects.

@param name a name for the cache.
@param maxSize the maximum size of the cache in bytes. -1 means the cache
     has no max size.
@param maxLifetime the maximum amount of time objects can exist in
     cache before being deleted. -1 means objects never expire.
xmppserver/src/main/java/org/jivesoftware/util/cache/DefaultCache.java