LiveKit C++ Client SDK v1.4.0
Real-time audio/video/data SDK for C++
Loading...
Searching...
No Matches
livekit::CachingTokenSource Class Referencefinal

Decorator that adds JWT-aware caching to another configurable token source. More...

#include <token_source.h>

Inheritance diagram for livekit::CachingTokenSource:
Collaboration diagram for livekit::CachingTokenSource:

Public Member Functions

std::future< Result< TokenSourceResponse, TokenSourceError > > fetch (const TokenRequestOptions &options={}) override
 Fetch connection credentials.
 
void invalidate ()
 Clear any cached credentials so the next fetch re-queries the inner source.
 
std::optional< TokenSourceResponsecachedResponse () const
 Return the currently cached credentials, if any.
 

Static Public Member Functions

static std::unique_ptr< CachingTokenSourcecreate (std::unique_ptr< TokenSourceConfigurable > inner)
 Wrap inner with JWT-aware caching.
 

Detailed Description

Decorator that adds JWT-aware caching to another configurable token source.

Wrap CustomTokenSource, EndpointTokenSource, or SandboxTokenSource to reduce token fetch calls. A cached response is reused until the request options change or the JWT expires. Call invalidate to force the next fetch to bypass the cache.

Member Function Documentation

◆ cachedResponse()

std::optional< TokenSourceResponse > livekit::CachingTokenSource::cachedResponse ( ) const

Return the currently cached credentials, if any.

Returns
The cached response, or std::nullopt when nothing is cached.

◆ create()

static std::unique_ptr< CachingTokenSource > livekit::CachingTokenSource::create ( std::unique_ptr< TokenSourceConfigurable inner)
static

Wrap inner with JWT-aware caching.

Cached values are keyed by TokenRequestOptions.

Parameters
innerConfigurable token source to cache.
Returns
A configurable token source that caches inner responses.

◆ fetch()

std::future< Result< TokenSourceResponse, TokenSourceError > > livekit::CachingTokenSource::fetch ( const TokenRequestOptions options = {})
overridevirtual

Fetch connection credentials.

Parameters
optionsConnection parameters encoded into the token request.
Returns
Future resolving to connection details or an error.

Implements livekit::TokenSourceConfigurable.


The documentation for this class was generated from the following file: