C# Class Couchbase.AspNet.SessionState.CouchbaseSessionStateProvider

Inheritance: System.Web.SessionState.SessionStateStoreProviderBase
Show file Open project: couchbaselabs/couchbase-aspnet Class Usage Examples

Public Properties

Property Type Description
DataPrefix string
HeaderPrefix string

Public Methods

Method Description
Application_End ( object sender, EventArgs e ) : void

Handles the End event of the Application control.

CouchbaseSessionStateProvider ( ) : System

Required default ctor for ASP.NET

CouchbaseSessionStateProvider ( IBucket bucket ) : System

For unit testing only.

CreateNewStoreData ( HttpContext context, int timeout ) : System.Web.SessionState.SessionStateStoreData

Takes as input the HttpContext instance for the current request and the Timeout value for the current session, and returns a new SessionStateStoreData object with an empty ISessionStateItemCollection object, an HttpStaticObjectsCollection collection, and the specified Timeout value. The HttpStaticObjectsCollection instance for the ASP.NET application can be retrieved using the GetSessionStaticObjects method.

CreateUninitializedItem ( HttpContext context, string id, int timeout ) : void

Creates an uninitialized item in the database. This is only used for cookieless sessions regenerateExpiredSessionId attribute is set to true, which causes SessionStateModule to generate a new SessionID value when an expired session ID is encountered.

Dispose ( ) : void

Handle disposing of the session-state store object

EndRequest ( HttpContext context ) : void

Takes as input the HttpContext instance for the current request and performs any cleanup required by the session-state store provider.

GetItem ( HttpContext context, string id, bool &locked, System.TimeSpan &lockAge, object &lockId, SessionStateActions &actions ) : System.Web.SessionState.SessionStateStoreData

Returns read-only session-state data from the session data store

GetItemExclusive ( HttpContext context, string id, bool &locked, System.TimeSpan &lockAge, object &lockId, SessionStateActions &actions ) : System.Web.SessionState.SessionStateStoreData

Returns read-write session-state data from the session data store

GetSessionStoreItem ( IBucket bucket, HttpContext context, bool acquireLock, string id, bool &locked, System.TimeSpan &lockAge, object &lockId, SessionStateActions &actions ) : SessionStateItem

Retrieves the session data from the data source. If the lockRecord parameter is true (in the case of GetItemExclusive), then the record is locked and we return a new lockId and lockAge.

Initialize ( string name, NameValueCollection config ) : void

Function to initialize the provider

InitializeRequest ( HttpContext context ) : void

Takes as input the HttpContext instance for the current request and performs any initialization required by the session-state store provider.

ReleaseItemExclusive ( HttpContext context, string id, object lockId ) : void

Releases a lock on an item in the session data store

RemoveItem ( HttpContext context, string id, object lockId, System.Web.SessionState.SessionStateStoreData item ) : void

Deletes item data from the session data store

ResetItemTimeout ( HttpContext context, string id ) : void

Updates the expiration date and time of an item in the session data store

SetAndReleaseItemExclusive ( HttpContext context, string id, System.Web.SessionState.SessionStateStoreData item, object lockId, bool newItem ) : void

Updates the session-item information in the session-state data store with values from the current request, and clears the lock on the data

SetItemExpireCallback ( SessionStateItemExpireCallback expireCallback ) : bool

Function to set the session data expiration callback. Since this is not supported by our database, we simply return false here and do manual session cleanup.

Method Details

Application_End() public method

Handles the End event of the Application control.
public Application_End ( object sender, EventArgs e ) : void
sender object The source of the event.
e System.EventArgs The instance containing the event data.
return void

CouchbaseSessionStateProvider() public method

Required default ctor for ASP.NET
public CouchbaseSessionStateProvider ( ) : System
return System

CouchbaseSessionStateProvider() public method

For unit testing only.
public CouchbaseSessionStateProvider ( IBucket bucket ) : System
bucket IBucket
return System

CreateNewStoreData() public method

Takes as input the HttpContext instance for the current request and the Timeout value for the current session, and returns a new SessionStateStoreData object with an empty ISessionStateItemCollection object, an HttpStaticObjectsCollection collection, and the specified Timeout value. The HttpStaticObjectsCollection instance for the ASP.NET application can be retrieved using the GetSessionStaticObjects method.
public CreateNewStoreData ( HttpContext context, int timeout ) : System.Web.SessionState.SessionStateStoreData
context System.Web.HttpContext HttpContext for the current request
timeout int Timeout value for the session
return System.Web.SessionState.SessionStateStoreData

CreateUninitializedItem() public method

Creates an uninitialized item in the database. This is only used for cookieless sessions regenerateExpiredSessionId attribute is set to true, which causes SessionStateModule to generate a new SessionID value when an expired session ID is encountered.
public CreateUninitializedItem ( HttpContext context, string id, int timeout ) : void
context System.Web.HttpContext HttpContext for the current request
id string Session ID for the new session
timeout int Timeout value for the session
return void

Dispose() public method

Handle disposing of the session-state store object
public Dispose ( ) : void
return void

EndRequest() public method

Takes as input the HttpContext instance for the current request and performs any cleanup required by the session-state store provider.
public EndRequest ( HttpContext context ) : void
context System.Web.HttpContext HttpContext for the current request
return void

GetItem() public method

Returns read-only session-state data from the session data store
public GetItem ( HttpContext context, string id, bool &locked, System.TimeSpan &lockAge, object &lockId, SessionStateActions &actions ) : System.Web.SessionState.SessionStateStoreData
context System.Web.HttpContext HttpContext for the current request
id string Session ID for the session
locked bool Returns true if the session item is locked, otherwise false
lockAge System.TimeSpan Returns the amount of time that the item has been locked
lockId object Returns lock identifier for the current request
actions SessionStateActions Indicates whether the current sessions is an uninitialized, cookieless session
return System.Web.SessionState.SessionStateStoreData

GetItemExclusive() public method

Returns read-write session-state data from the session data store
public GetItemExclusive ( HttpContext context, string id, bool &locked, System.TimeSpan &lockAge, object &lockId, SessionStateActions &actions ) : System.Web.SessionState.SessionStateStoreData
context System.Web.HttpContext HttpContext for the current request
id string Session ID for the session
locked bool Returns true if the session item is locked, otherwise false
lockAge System.TimeSpan Returns the amount of time that the item has been locked
lockId object Returns lock identifier for the current request
actions SessionStateActions Indicates whether the current sessions is an uninitialized, cookieless session
return System.Web.SessionState.SessionStateStoreData

GetSessionStoreItem() public static method

Retrieves the session data from the data source. If the lockRecord parameter is true (in the case of GetItemExclusive), then the record is locked and we return a new lockId and lockAge.
public static GetSessionStoreItem ( IBucket bucket, HttpContext context, bool acquireLock, string id, bool &locked, System.TimeSpan &lockAge, object &lockId, SessionStateActions &actions ) : SessionStateItem
bucket IBucket Reference to the couchbase bucket we are using
context System.Web.HttpContext HttpContext for the current request
acquireLock bool True to aquire the lock, false to not aquire it
id string Session ID for the session
locked bool Returns true if the session item is locked, otherwise false
lockAge System.TimeSpan Returns the amount of time that the item has been locked
lockId object Returns lock identifier for the current request
actions SessionStateActions Indicates whether the current sessions is an uninitialized, cookieless session
return SessionStateItem

Initialize() public method

Function to initialize the provider
public Initialize ( string name, NameValueCollection config ) : void
name string Name of the element in the configuration file
config NameValueCollection Configuration values for the provider from the Web.config file
return void

InitializeRequest() public method

Takes as input the HttpContext instance for the current request and performs any initialization required by the session-state store provider.
public InitializeRequest ( HttpContext context ) : void
context System.Web.HttpContext HttpContext for the current request
return void

ReleaseItemExclusive() public method

Releases a lock on an item in the session data store
public ReleaseItemExclusive ( HttpContext context, string id, object lockId ) : void
context System.Web.HttpContext HttpContext for the current request
id string Session ID for the session
lockId object The lock identifier for the current request
return void

RemoveItem() public method

Deletes item data from the session data store
public RemoveItem ( HttpContext context, string id, object lockId, System.Web.SessionState.SessionStateStoreData item ) : void
context System.Web.HttpContext HttpContext for the current request
id string Session ID for the session
lockId object The lock identifier for the current request
item System.Web.SessionState.SessionStateStoreData Item to be deleted (ignored)
return void

ResetItemTimeout() public method

Updates the expiration date and time of an item in the session data store
public ResetItemTimeout ( HttpContext context, string id ) : void
context System.Web.HttpContext HttpContext for the current request
id string Session ID for the session
return void

SetAndReleaseItemExclusive() public method

Updates the session-item information in the session-state data store with values from the current request, and clears the lock on the data
public SetAndReleaseItemExclusive ( HttpContext context, string id, System.Web.SessionState.SessionStateStoreData item, object lockId, bool newItem ) : void
context System.Web.HttpContext HttpContext for the current request
id string Session ID for the session
item System.Web.SessionState.SessionStateStoreData The session state item to be stored
lockId object The lock identifier for the current request
newItem bool True if this is a new session item, false if it is an existing item
return void

SetItemExpireCallback() public method

Function to set the session data expiration callback. Since this is not supported by our database, we simply return false here and do manual session cleanup.
public SetItemExpireCallback ( SessionStateItemExpireCallback expireCallback ) : bool
expireCallback SessionStateItemExpireCallback Session expiration callback to set
return bool

Property Details

DataPrefix public static property

Defines the prefix for the actual session store data stored in the Couchbase bucket. Must also be unique for the same reasons outlined above.
public static string DataPrefix
return string

HeaderPrefix public static property

Defines the prefix for header data in the Couchbase bucket. Must be unique to ensure it does not conflict with other applications that might be using the Couchbase bucket.
public static string HeaderPrefix
return string