Package io.github.mahmoudimus.quic.tls
Class ClientSessionMemoryCache
java.lang.Object
io.github.mahmoudimus.quic.tls.ClientSessionMemoryCache
- All Implemented Interfaces:
ClientSessionStore
A bounded, in-memory
ClientSessionStore: up to a number of servers, each with up to
8 tickets. A full cache forgets the server added first; a full
server entry forgets its oldest ticket. Tickets are taken newest first, and only once.
Thread-safe: a ReentrantLock guards the map.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default number of servers.static final intThe tickets kept per server, as rustls keeps.Fields inherited from interface io.github.mahmoudimus.quic.tls.ClientSessionStore
NONE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidput(String key, SessionTicket ticket) Keeps a ticket.intThe number of tickets kept for a server.Takes the newest ticket for a server, removing it.
-
Field Details
-
MAX_TICKETS_PER_SERVER
public static final int MAX_TICKETS_PER_SERVERThe tickets kept per server, as rustls keeps.- See Also:
-
DEFAULT_MAX_SERVERS
public static final int DEFAULT_MAX_SERVERSThe default number of servers.- See Also:
-
-
Constructor Details
-
ClientSessionMemoryCache
public ClientSessionMemoryCache()A cache for 256 servers. -
ClientSessionMemoryCache
public ClientSessionMemoryCache(int maxServers) A cache.- Parameters:
maxServers- the most servers to remember; 0 remembers none
-
-
Method Details
-
put
Description copied from interface:ClientSessionStoreKeeps a ticket.- Specified by:
putin interfaceClientSessionStore- Parameters:
key- the server it is for: its name, or another key the caller uses consistentlyticket- the ticket
-
take
Description copied from interface:ClientSessionStoreTakes the newest ticket for a server, removing it.- Specified by:
takein interfaceClientSessionStore- Parameters:
key- the server- Returns:
- the ticket, or null if there is none
-
size
The number of tickets kept for a server.- Parameters:
key- the server- Returns:
- the count
-