SSL_SESSION_CACHE_API(3erl)
π ssl_session_cache_api β the TLS session cache API, bestie π
Okay so this is ssl_session_cache_api, and it lives in the Erlang/OTP manual pages (module definitions territory, iykyk). Welcome to the callback-module glow-up π
β¨ NAME β¨
ssl_session_cache_api β literally the TLS session cache API, no cap.
πΈ DESCRIPTION πΈ
So here's the vibe: this page defines the API for the TLS session cache (pre TLS-1.3, okurrr), and the whole point is that you can swap out the data storage scheme entirely by defining a brand-new callback module that implements this API. That's it, that's the gig π«Ά
π¦ DATA TYPES π¦
session_cache_ref() = any()
session_cache_key() = {partial_key(), ssl:session_id()}
session_cache_key()β a key to an entry in the session cache β¨
partial_key()
partial_key()β the opaque part of the key. The callback does not need to handle it, so don't stress about it π
session()
session()β the session data that gets stored for each session. The main character of the storage situation π
π₯ EXPORTS π₯
π Module:delete(Cache, Key) -> _
Types:
Cache = session_cache_ref()
Key = session_cache_key()
Deletes a cache entry. Heads up: this is only called from the cache handling process, so don't go calling it from wherever π
π Module:foldl(Fun, Acc0, Cache) -> Acc
Types:
Fun = fun()
Acc0 = Acc = term()
Cache = session_cache_ref()
Calls Fun(Elem, AccIn) on successive elements of the cache, starting with AccIn == Acc0. Fun/2 must return a new accumulator, which then gets passed to the next call. The function returns the final value of the accumulator β and if the cache is empty, you just get Acc0 back. Slay, classic fold behaviour β
Note: since OTP-23.3 this function is only used on the client side, and it does not need to be implemented for a server cache. Not me telling you to skip it π
π Module:init(Args) -> Cache
Types:
Cache = session_cache_ref()
Args = proplists:proplist()
Includes the property {role, client | server}. Currently that's the only predefined property, but you can also have user-defined properties. See also the application environment variable session_cb_init_args π
Performs possible initializations of the cache and returns a reference to it, which is then used as a parameter to the other API functions. It's called by the cache handling process's init function β so it's got the exact same requirements on it as a normal process init function, no pressure π
Fun fact: this function is called twice when starting the SSL application β once with the role client and once with the role server β because the SSL application must be prepared to take on both roles. Versatile icon behaviour, honestly π¦
π Module:lookup(Cache, Key) -> Entry
Types:
Cache = session_cache_ref()
Key = session_cache_key()
Session = session() | undefined
Looks up a cache entry. This one is to be callable from any process, okay? Everyone gets access π
π Module:select_session(Cache, PartialKey) -> [Session]
Types:
Cache = session_cache_ref()
PartialKey = partial_key()
Session = session()
Selects sessions that can be reused β meaning sessions that include PartialKey in their key. This is to be callable from any process too π«Ά
Note: sinceOTP-23.3this function is only used on the client side and does not need to be implemented for a server cache. Same energy asfoldl, fr fr π
π Module:size(Cache) -> integer()
Types:
Cache = session_cache_ref()
Returns the number of sessions in the cache. But listen β if the size exceeds the maximum number of sessions, the current cache entries get invalidated regardless of their remaining lifetime. Like, all of them. Rude but that's the rule π Callable from any process β¨
π Module:terminate(Cache) -> _
Types:
Cache = session_cache_ref()
As returned by init/0
Takes care of any possible cleanup that's needed when the cache handling process terminates. The graceful exit moment, we love to see it π
π Module:update(Cache, Key, Session) -> _
Types:
Cache = session_cache_ref()
Key = session_cache_key()
Session = session()
Caches a new session, or updates one that's already cached. This one is only called from the cache handling process β so stay in your lane, respectfully π
Okay that's the whole page, bestie. Go forth and implement your callback module with main character energy π
Ericsson AB made this, it's ssl 10.9.1.3, and this page is ssl_session_cache_api(3erl) β mwah, bye! π
πβ¨
π¦ where this page comes from
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4 Β· Apache-2.0
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4.8 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms