fastcgi++
Public Types | Public Member Functions | Private Attributes
Fastcgipp::Http::Sessions< T > Class Template Reference

Container for HTTP sessions. More...

#include <http.hpp>

List of all members.

Public Types

typedef std::map< SessionId, T >
::iterator 
iterator
typedef std::map< SessionId, T >
::const_iterator 
const_iterator

Public Member Functions

 Sessions (int keepAlive_, int cleanupFrequency_)
 Constructor takes session keep alive times and cleanup frequency.
void cleanup ()
 Clean out old sessions.
iterator generate (const T &value_=T())
 Generates a new session pair with a random ID value.
boost::posix_time::ptime getExpiry (const_iterator it) const

Private Attributes

const boost::posix_time::seconds keepAlive
 Amount of seconds to keep sessions around for.
const boost::posix_time::seconds cleanupFrequency
 How often (in seconds) the container should find old sessions and delete them.
boost::posix_time::ptime cleanupTime
 The time that the next session cleanup should be done.

Detailed Description

template<class T>
class Fastcgipp::Http::Sessions< T >

Container for HTTP sessions.

In almost all ways this class behaves like an std::map. The sole addition is a mechanism for clearing out expired sessions based on a keep alive time and a frequency of deletion. The first part of the std::pair<> is a SessionId object, and the second is a object of class T (passed as the template parameter.

Template Parameters:
TClass containing session data.

Definition at line 509 of file http.hpp.


Member Typedef Documentation

template<class T>
typedef std::map<SessionId, T>::const_iterator Fastcgipp::Http::Sessions< T >::const_iterator

Definition at line 528 of file http.hpp.

template<class T>
typedef std::map<SessionId, T>::iterator Fastcgipp::Http::Sessions< T >::iterator

Definition at line 527 of file http.hpp.


Constructor & Destructor Documentation

template<class T>
Fastcgipp::Http::Sessions< T >::Sessions ( int  keepAlive_,
int  cleanupFrequency_ 
)
inline

Constructor takes session keep alive times and cleanup frequency.

Parameters:
[in]keepAlive_Amount of seconds a session will stay alive for.
[in]cleanupFrequency_How often (in seconds) the container should find old sessions and delete them.

Definition at line 535 of file http.hpp.


Member Function Documentation

template<class T >
void Fastcgipp::Http::Sessions< T >::cleanup ( )

Clean out old sessions.

Calling this function will clear out any expired sessions from the container. This function must be called for any cleanup to take place, however calling may not actually cause a cleanup. The amount of seconds specified in cleanupFrequency must have expired since the last cleanup for it to actually take place.

Definition at line 558 of file http.hpp.

template<class T>
Fastcgipp::Http::Sessions< T >::iterator Fastcgipp::Http::Sessions< T >::generate ( const T &  value_ = T())

Generates a new session pair with a random ID value.

Parameters:
[in]value_Value to place into the data section.
Returns:
Iterator pointing to the newly created session.

Definition at line 646 of file http.hpp.

template<class T>
boost::posix_time::ptime Fastcgipp::Http::Sessions< T >::getExpiry ( const_iterator  it) const
inline

Definition at line 553 of file http.hpp.

References Fastcgipp::Http::Sessions< T >::keepAlive.


Member Data Documentation

template<class T>
const boost::posix_time::seconds Fastcgipp::Http::Sessions< T >::cleanupFrequency
private

How often (in seconds) the container should find old sessions and delete them.

Definition at line 520 of file http.hpp.

template<class T>
boost::posix_time::ptime Fastcgipp::Http::Sessions< T >::cleanupTime
private

The time that the next session cleanup should be done.

Definition at line 525 of file http.hpp.

template<class T>
const boost::posix_time::seconds Fastcgipp::Http::Sessions< T >::keepAlive
private

Amount of seconds to keep sessions around for.

Definition at line 515 of file http.hpp.

Referenced by Fastcgipp::Http::Sessions< T >::getExpiry().


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