@Override
    public synchronized V get(final Object key) {
        checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
        // First, clear all entries that have been in cache longer than the
        // maximum defined age.
        deleteExpiredEntries();

        final DefaultCache.CacheObject<V> cacheObject = map.get(key);
        if (cacheObject == null) {
            // The object didn't exist in cache, so increment cache misses.
            cacheMisses++;
            return null;
        }

        // The object exists in cache, so increment cache hits. Also, increment
        // the object's read count.
        cacheHits++;
        cacheObject.readCount++;

        // Remove the object from it's current place in the cache order list,
        // and re-insert it at the front of the list.
        cacheObject.lastAccessedListNode.remove();
        //noinspection unchecked
        lastAccessedList.addFirst((LinkedListNode<K>) cacheObject.lastAccessedListNode);

        return cacheObject.object;
    }
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