Package com.glideapi.session
Class ThreadLocalStrategy
java.lang.Object
com.glideapi.session.ThreadLocalStrategy
- All Implemented Interfaces:
SessionStrategy
Session strategy that maintains one session per thread.
This provides a good balance between performance and isolation.
Each thread gets its own session, avoiding contention while reusing sessions within the same thread.
Best for: Multi-threaded applications where each thread handles multiple requests.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClear any cached sessions.Get a valid session, creating a new one if necessary.getSession(String scope) Get a valid session with specific scopes, creating a new one if necessary.Get a valid session asynchronously.
-
Constructor Details
-
ThreadLocalStrategy
-
-
Method Details
-
getSession
Description copied from interface:SessionStrategyGet a valid session, creating a new one if necessary.- Specified by:
getSessionin interfaceSessionStrategy- Returns:
- A valid session
- Throws:
Exception- if session creation fails
-
getSession
Description copied from interface:SessionStrategyGet a valid session with specific scopes, creating a new one if necessary.- Specified by:
getSessionin interfaceSessionStrategy- Parameters:
scope- Space-separated list of scopes to request- Returns:
- A valid session
- Throws:
Exception- if session creation fails
-
getSessionAsync
Description copied from interface:SessionStrategyGet a valid session asynchronously.- Specified by:
getSessionAsyncin interfaceSessionStrategy- Returns:
- CompletableFuture that will complete with a valid session
-
clearCache
public void clearCache()Description copied from interface:SessionStrategyClear any cached sessions. Useful for forcing a fresh session on the next request.- Specified by:
clearCachein interfaceSessionStrategy
-