SSL_CTX_SESS_SET_CACHE_SIZE(3ossl)
π SSL_CTX_SESS_SET_CACHE_SIZE(3ossl) β bestie's guide to session cache size π
okay so this is an OpenSSL manpage, section 3ossl β yes the whole name is a mouthful, we don't gatekeep, come on in β¨
πΈ NAME πΈ
SSL_CTX_sess_set_cache_size, SSL_CTX_sess_get_cache_size β literally just here to manipulate the session cache size, that's the whole vibe π«Ά
β¨ SYNOPSIS β¨
#include <openssl/ssl.h>
long SSL_CTX_sess_set_cache_size(SSL_CTX *ctx, long t);
long SSL_CTX_sess_get_cache_size(SSL_CTX *ctx);
π DESCRIPTION π
SSL_CTX_sess_set_cache_size()β sets the size of the internal session cache of contextctxtot. and likeβ¦ heads up bestie, this value is a hint, not an absolute. it's giving "suggestion box" energy, not "contract" energy β see the NOTES below, iykyk πSSL_CTX_sess_get_cache_size()β returns the currently valid session cache size. that's it, that's the function, slay π
π¦ NOTES π¦
so the internal session cache size defaults to SSL_SESSION_CACHE_MAX_SIZE_DEFAULT, which is currently 1024*20, meaning up to 20000 sessions can be held at once. not me doing math in public π you can change this size with the SSL_CTX_sess_set_cache_size() call.
a special case you should know about: the size 0 means unlimited size. periodt, no cap π
if adding the session makes the cache exceed its size, then unused sessions get dropped from the end of the cache. cache space may also be reclaimed by calling SSL_CTX_flush_sessions(3) to remove expired sessions β¨
and now the important part β if the size of the session cache is reduced and more sessions are already chilling in the session cache, old sessions will be removed at the next time a session shall be added. that removal is not synchronized with the expiration of sessions. so likeβ¦ be aware, it's not doing a little dance in sync with expiry, it's just doing its own thing π
π₯ RETURN VALUES π₯
SSL_CTX_sess_set_cache_size()returns the previously valid size πSSL_CTX_sess_get_cache_size()returns the currently valid size π
π SEE ALSO π
ssl(7), SSL_CTX_set_session_cache_mode(3), SSL_CTX_sess_number(3), SSL_CTX_flush_sessions(3) β go read those too bestie, knowledge is free β¨
π COPYRIGHT π
Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
fr fr read the license before you use this, it's not decorative π
and that's the whole page bestie π§ this chaotic little drop shipped with OpenSSL 3.5.0, dated 2026-09-25 β mwah, go forth and cache responsibly πβ
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms