SSL_CTX_SESS_SET_CACHE_SIZE(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’– SSL_CTX_SESS_SET_CACHE_SIZE(3ossl) β€” the OpenSSL glow-up πŸ’–

okay bestie, so this one's a 3ossl manual page from the OpenSSL fam, and it's literally all about ✨session cache size✨ β€” a.k.a. how many sessions your SSL_CTX is allowed to keep cozy inside its internal cache. it's short, it's sweet, and it ate, honestly.

🌸 NAME 🌸

SSL_CTX_sess_set_cache_size, SSL_CTX_sess_get_cache_size β€” manipulate session cache size πŸŽ€


✨ 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 ngl, this value is a hint, not an absolute β€” the notes below spill the tea on that one πŸ’…
  • SSL_CTX_sess_get_cache_size() β€” returns the currently valid session cache size. that's it, that's the whole function, she's simple and she serves 🫢

πŸ”₯ NOTES πŸ”₯

so the default internal session cache size is SSL_SESSION_CACHE_MAX_SIZE_DEFAULT, which is currently 1024*20 β€” meaning up to 20000 sessions can be held. iconic capacity, honestly πŸ‘‘

you can change that size with SSL_CTX_sess_set_cache_size(). and there's a special case bestie, listen: a size of 0 means unlimited size. no cap, zero means infinite here πŸ™ˆ

if adding a session makes the cache exceed its size, then unused sessions get dropped from the end of the cache. cache space can also be reclaimed by calling SSL_CTX_flush_sessions(3) to remove expired sessions 🧹✨

and if you reduce the size of the session cache while more sessions are already chilling in it, old sessions get removed the next time a session shall be added. heads up though: this removal is not synchronized with the expiration of sessions. so it's giving chaotic timing, not organized β€” keep that in mind πŸ’€

πŸ’œ RETURN VALUES πŸ’œ

  • SSL_CTX_sess_set_cache_size() β€” returns the previously valid size (yes, the old one, it's cute like that)
  • 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 these too, they're the supporting cast and they understood the assignment πŸŽ€

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 do anything, bestie β€” it's the rules πŸ’…

and that's the whole page, mwah πŸ’‹ this was OpenSSL 3.5.6, dated 2026-04-07, signing off with main character energy πŸŒŸπŸ’–πŸ¦‹

πŸ“¦ where this page comes from