@Override
    public void userAvailable(Presence presence) {
        // Delete the last unavailable presence of this user since the user is now
        // available. Only perform this operation if this is an available presence sent to
        // THE SERVER and the presence belongs to a local user.
        if (presence.getTo() == null && userManager.isRegisteredUser(presence.getFrom(), false)) {
            String username = presence.getFrom().getNode();

            // Optimization: only delete the unavailable presence information if this
            // is the first session created on the server.
            if (sessionManager.getSessionCount(username) > 1) {
                return;
            }

            deleteOfflinePresenceFromDB(username);

            // Remove data from cache.
            offlinePresenceCache.remove(username);
            lastActivityCache.remove(username);
        }
    }
Simple in memory implementation of the PresenceManager interface.

@author Iain Shigeoka
xmppserver/src/main/java/org/jivesoftware/openfire/spi/PresenceManagerImpl.java