SSL_CTX_SESS_SET_CACHE_SIZE(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… 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 context ctx to t. 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 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