Package org.conscrypt
Class FileClientSessionCache.Impl
java.lang.Object
org.conscrypt.FileClientSessionCache.Impl
- All Implemented Interfaces:
SSLClientSessionCache
- Enclosing class:
FileClientSessionCache
This cache creates one file per SSL session using "host.port" for
the file name. Files are created or replaced when session data is put
in the cache (see
putSessionData(javax.net.ssl.SSLSession, byte[])
). Files are read on
cache hits, but not on cache misses.
When the number of session files exceeds MAX_SIZE, we delete the least-recently-used file. We don't current persist the last access time, so the ordering actually ends up being least-recently-modified in some cases and even just "not accessed in this process" if the filesystem doesn't track last modified times.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
private static String
Gets the file name for the given host and port.byte[]
getSessionData
(String host, int port) Gets data from a pre-existing session for a given server host and port.private void
Lazily updates accessOrder to know about all files as opposed to just the files accessed since this process started.(package private) static void
logReadError
(String host, File file, Throwable t) (package private) static void
logWriteError
(String host, File file, Throwable t) private void
makeRoom()
Deletes old files if necessary.Creates a new access-ordered linked hash map.void
putSessionData
(SSLSession session, byte[] sessionData) Stores session data for the given session.
-
Field Details
-
directory
Directory to store session files in. -
accessOrder
Map of name -> File. Keeps track of the order files were accessed in. -
size
int sizeThe number of files on disk. -
initialFiles
String[] initialFilesThe initial set of files. We use this to defer adding information about all files to accessOrder until necessary.
-
-
Constructor Details
-
Impl
Impl(File directory) throws IOException Constructs a new cache backed by the given directory.- Throws:
IOException
-
-
Method Details
-
newAccessOrder
Creates a new access-ordered linked hash map. -
fileName
Gets the file name for the given host and port. -
getSessionData
Description copied from interface:SSLClientSessionCache
Gets data from a pre-existing session for a given server host and port.- Specified by:
getSessionData
in interfaceSSLClientSessionCache
- Parameters:
host
- fromSSLSession.getPeerHost()
port
- fromSSLSession.getPeerPort()
- Returns:
- the session data or null if none is cached
-
logReadError
-
putSessionData
Description copied from interface:SSLClientSessionCache
Stores session data for the given session.- Specified by:
putSessionData
in interfaceSSLClientSessionCache
- Parameters:
session
- to cache data forsessionData
- to cache
-
makeRoom
private void makeRoom()Deletes old files if necessary. -
indexFiles
private void indexFiles()Lazily updates accessOrder to know about all files as opposed to just the files accessed since this process started. -
delete
-
logWriteError
-