final void cacheSession(NativeSslSession session) {
        byte[] id = session.getId();
        if (id == null || id.length == 0) {
            return;
        }

        synchronized (sessions) {
            ByteArray key = new ByteArray(id);
            if (sessions.containsKey(key)) {
                removeSession(sessions.get(key));
            }
            // Let the subclass know.
            onBeforeAddSession(session);

            sessions.put(key, session);
        }
    }
Adds the given session to the cache.
common/src/main/java/org/conscrypt/AbstractSessionContext.java