Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #6752 - Extensible DefaultSessionCache map implementation #6758

Merged
merged 3 commits into from Sep 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -13,6 +13,7 @@

package org.eclipse.jetty.server.session;

import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Function;
Expand All @@ -28,7 +29,7 @@
/**
* DefaultSessionCache
*
* A session store that keeps its sessions in memory in a concurrent map
* A session store that keeps its sessions in memory within a concurrent map
*/
@ManagedObject
public class DefaultSessionCache extends AbstractSessionCache
Expand All @@ -38,16 +39,26 @@ public class DefaultSessionCache extends AbstractSessionCache
/**
* The cache of sessions in a concurrent map
*/
protected ConcurrentMap<String, Session> _sessions = new ConcurrentHashMap<>();
private final ConcurrentMap<String, Session> _sessions;

private final CounterStatistic _stats = new CounterStatistic();

/**
* @param manager The SessionHandler related to this SessionCache
*/
public DefaultSessionCache(SessionHandler manager)
{
this(manager, new ConcurrentHashMap<>());
}

/**
* @param manager The SessionHandler related to this SessionCache
* @param sessions The session map implementation to use
*/
public DefaultSessionCache(SessionHandler manager, ConcurrentMap<String, Session> sessions)
{
super(manager);
_sessions = Objects.requireNonNull(sessions, "Session Map may not be null");
}

/**
Expand Down