|
fastcgi++
A C++ FastCGI/Web API
|
Container for HTTP sessions. More...
#include <fastcgi++/http.hpp>
Public Member Functions | |
| Sessions (unsigned int keepAlive) | |
| Constructor takes session keep alive times. More... | |
| std::shared_ptr< const T > | get (const SessionId &id) |
| Get session data from session ID. More... | |
| size_t | size () const |
| How many active sessions are there? More... | |
| SessionId | generate (const std::shared_ptr< const T > &data) |
| Generates a new session. More... | |
| void | erase (const SessionId &id) |
| Erase a session. More... | |
| const char * | expiration () const |
| Expiration string for setting cookies. More... | |
Private Member Functions | |
| void | setExpiration () |
| Internal helper for building the m_expiration string. More... | |
Private Attributes | |
| const unsigned int | m_keepAlive |
| Amount of seconds to keep sessions around for. More... | |
| std::time_t | m_cleanupTime |
| The time that the next session cleanup should be done. More... | |
| std::map< SessionId, std::shared_ptr< const T > > | m_sessions |
| Actual container of sessions. More... | |
| std::mutex | m_mutex |
| Thread safe all operations. More... | |
| char | m_expiration [2][expirationLength] |
| Internal string for cookie expirations. More... | |
| std::atomic< const char * > | m_expirationPtr |
| Point for the current expiration string. More... | |
Static Private Attributes | |
| static const size_t | expirationLength = 30 |
| Length of expiration string (with null terminator) More... | |
Container for HTTP sessions.
In many ways this class behaves like an std::map. Additions include a mechanism for clearing out expired sessions based on a keep alive time and a frequency of deletion, and full thread safety. Basically it contains all session data and associates it with ID values.
Session data is only available as constant in order to ensure thread safety when accessing the data. It is not only possible, but very probable, that multiple requests/threads will be accessing the same session data simultaneously.
| T | Class containing session data. |
|
inline |
|
inline |
|
inline |
| Fastcgipp::Http::SessionId Fastcgipp::Http::Sessions< T >::generate | ( | const std::shared_ptr< const T > & | data | ) |
| std::shared_ptr< const T > Fastcgipp::Http::Sessions< T >::get | ( | const SessionId & | id | ) |
|
private |
|
inline |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |
|
private |
1.8.11