SSL_CTX_SESS_SET_CACHE_SIZE(3SSL)

πŸ’– SSL_CTX_SESS_SET_CACHE_SIZE πŸ’–

okay bestie so this is an OpenSSL page, from the 3SSL manual β€” literally the session cache size lore you've been missing πŸŽ€

✨ 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. bestie listen β€” this value is a hint and not an absolute, ok? like it's giving suggestion, not contract. the notes below spill the tea β˜•

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's iconic πŸ‘‘


⭐ NOTES ⭐

The internal session cache size is SSL_SESSION_CACHE_MAX_SIZE_DEFAULT, currently 1024*20, so that up to 20000 sessions can be held. cute right? and you can modify this size using the SSL_CTX_sess_set_cache_size() call. A special case is the size 0, which is used for unlimited size β€” yes ma'am, zero means infinity, it's giving main character energy, no cap 🌈

If adding the session makes the cache exceed its size, then unused sessions are dropped from the end of the cache. Cache space may also be reclaimed by calling SSL_CTX_flush_sessions(3) to remove expired sessions. cleanup era ✨

If the size of the session cache is reduced and more sessions are already in the session cache, old session will be removed at the next time a session shall be added. This removal is not synchronized with the expiration of sessions β€” so like, she's not on the same schedule as the expiry girlies, they don't text each other πŸ’€


πŸ’œ RETURN VALUES πŸ’œ

SSL_CTX_sess_set_cache_size() returns the previously valid size. (the old girl, gone but not forgotten 🫢)

SSL_CTX_sess_get_cache_size() returns the currently valid size.


πŸŽ€ SEE ALSO πŸŽ€

go read those too, iykyk, they're all in the same friend group πŸ’–


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>.


and that's the whole page bestie, mwah πŸ’… this was version 4.0.3, dated 2026-09-29, from the SSL_CTX_SESS_SET_CACHE_SIZE(3SSL) manual β€” slay, go forth and cache responsibly πŸ¦‹βœ¨

πŸ“¦ where this page comes from