C# Class Raven.AspNet.SessionState.RavenSessionStateStoreProvider

An ASP.NET session-state store-provider implementation (http://msdn.microsoft.com/en-us/library/ms178588.aspx) using RavenDb (http://ravendb.net) for persistence.
Inheritance: System.Web.SessionState.SessionStateStoreProviderBase, IDisposable
ファイルを表示 Open project: MJRichardson/RavenDbSessionStateStoreProvider Class Usage Examples

Private Properties

Property Type Description
Deserialize System.Web.SessionState.SessionStateStoreData
GetSessionStaticObjects System.Web.HttpStaticObjectsCollection
GetSessionStoreItem System.Web.SessionState.SessionStateStoreData
Initialize void
Serialize string

Public Methods

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

returns a new SessionStateStoreData object with an empty ISessionStateItemCollection object, an HttpStaticObjectsCollection collection, and the specified Timeout value.

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

Adds an uninitialized item to the session data store.

Dispose ( ) : void
EndRequest ( HttpContext context ) : void

Performs any cleanup required by your session-state store provider.

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

This method performs the same work as the GetItemExclusive method, except that it does not attempt to lock the session item in the data store.

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

Retrieves session values and information from the session data store and locks the session-item data at the data store for the duration of the request.

Initialize ( string name, System config ) : void
InitializeRequest ( HttpContext context ) : void

Performs any initialization required by your session-state store provider.

RavenSessionStateStoreProvider ( ) : System

Public parameterless constructor

RavenSessionStateStoreProvider ( IDocumentStore documentStore ) : System

Constructor accepting a document store instance, used for testing.

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

Releases the lock on an item in the session data store.

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

deletes the session information from the data store where the data store item matches the supplied SessionID value, the current application, and the supplied lock identifier.

ResetItemTimeout ( HttpContext context, string sessionId ) : void

Resets the expiry timeout for a session item.

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

If the newItem parameter is true, the SetAndReleaseItemExclusive method inserts a new item into the data store with the supplied values. Otherwise, the existing item in the data store is updated with the supplied values, and any lock on the data is released.

SetItemExpireCallback ( SessionStateItemExpireCallback expireCallback ) : bool

Takes as input a delegate that references the Session_OnEnd event defined in the Global.asax file. If the session-state store provider supports the Session_OnEnd event, a local reference to the SessionStateItemExpireCallback parameter is set and the method returns true; otherwise, the method returns false.

Private Methods

Method Description
Deserialize ( HttpContext context, string serializedItems, int timeout ) : System.Web.SessionState.SessionStateStoreData
GetSessionStaticObjects ( HttpContext context ) : System.Web.HttpStaticObjectsCollection
GetSessionStoreItem ( bool lockRecord, HttpContext context, string sessionId, bool &locked, System.TimeSpan &lockAge, object &lockId, SessionStateActions &actionFlags ) : System.Web.SessionState.SessionStateStoreData
Initialize ( string name, System config, IDocumentStore documentStore ) : void
Serialize ( System.Web.SessionState.SessionStateItemCollection items ) : string

Method Details

CreateNewStoreData() public method

returns a new SessionStateStoreData object with an empty ISessionStateItemCollection object, an HttpStaticObjectsCollection collection, and the specified Timeout value.
public CreateNewStoreData ( HttpContext context, int timeout ) : System.Web.SessionState.SessionStateStoreData
context System.Web.HttpContext The HttpContext instance for the current request
timeout int The expiry timeout in minutes.
return System.Web.SessionState.SessionStateStoreData

CreateUninitializedItem() public method

Adds an uninitialized item to the session data store.
public CreateUninitializedItem ( HttpContext context, string sessionId, int timeout ) : void
context System.Web.HttpContext The HttpContext instance for the current request
sessionId string The session identifier.
timeout int The expiry timeout in minutes.
return void

Dispose() public method

public Dispose ( ) : void
return void

EndRequest() public method

Performs any cleanup required by your session-state store provider.
public EndRequest ( HttpContext context ) : void
context System.Web.HttpContext The HttpContext instance for the current request
return void

GetItem() public method

This method performs the same work as the GetItemExclusive method, except that it does not attempt to lock the session item in the data store.
public GetItem ( HttpContext context, string sessionId, bool &locked, System.TimeSpan &lockAge, object &lockId, SessionStateActions &actions ) : System.Web.SessionState.SessionStateStoreData
context System.Web.HttpContext The HttpContext instance for the current request
sessionId string The session identifier.
locked bool An output parameter indicating whether the item is currently exclusively locked.
lockAge System.TimeSpan The age of the exclusive lock (if present)
lockId object The identifier of the exclusive lock (if present)
actions SessionStateActions Used with sessions whose Cookieless property is true, /// when the regenerateExpiredSessionId attribute is set to true. /// An actionFlags value set to InitializeItem (1) indicates that the entry in the session data store is a /// new session that requires initialization.
return System.Web.SessionState.SessionStateStoreData

GetItemExclusive() public method

Retrieves session values and information from the session data store and locks the session-item data at the data store for the duration of the request.
public GetItemExclusive ( HttpContext context, string sessionId, bool &locked, System.TimeSpan &lockAge, object &lockId, SessionStateActions &actions ) : System.Web.SessionState.SessionStateStoreData
context System.Web.HttpContext The HttpContext instance for the current request
sessionId string The session identifier.
locked bool An output parameter indicating whether the item is currently exclusively locked.
lockAge System.TimeSpan The age of the exclusive lock (if present)
lockId object The identifier of the exclusive lock (if present)
actions SessionStateActions Used with sessions whose Cookieless property is true, /// when the regenerateExpiredSessionId attribute is set to true. /// An actionFlags value set to InitializeItem (1) indicates that the entry in the session data store is a /// new session that requires initialization.
return System.Web.SessionState.SessionStateStoreData

Initialize() public method

public Initialize ( string name, System config ) : void
name string
config System
return void

InitializeRequest() public method

Performs any initialization required by your session-state store provider.
public InitializeRequest ( HttpContext context ) : void
context System.Web.HttpContext The HttpContext instance for the current request
return void

RavenSessionStateStoreProvider() public method

Public parameterless constructor
public RavenSessionStateStoreProvider ( ) : System
return System

RavenSessionStateStoreProvider() public method

Constructor accepting a document store instance, used for testing.
public RavenSessionStateStoreProvider ( IDocumentStore documentStore ) : System
documentStore IDocumentStore
return System

ReleaseItemExclusive() public method

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

RemoveItem() public method

deletes the session information from the data store where the data store item matches the supplied SessionID value, the current application, and the supplied lock identifier.
public RemoveItem ( HttpContext context, string sessionId, object lockId, System.Web.SessionState.SessionStateStoreData item ) : void
context System.Web.HttpContext The HttpContext instance for the current request
sessionId string The session identifier.
lockId object The exclusive-lock identifier.
item System.Web.SessionState.SessionStateStoreData
return void

ResetItemTimeout() public method

Resets the expiry timeout for a session item.
public ResetItemTimeout ( HttpContext context, string sessionId ) : void
context System.Web.HttpContext The HttpContext instance for the current request
sessionId string The session identifier.
return void

SetAndReleaseItemExclusive() public method

If the newItem parameter is true, the SetAndReleaseItemExclusive method inserts a new item into the data store with the supplied values. Otherwise, the existing item in the data store is updated with the supplied values, and any lock on the data is released.
public SetAndReleaseItemExclusive ( HttpContext context, string sessionId, System.Web.SessionState.SessionStateStoreData item, object lockId, bool newItem ) : void
context System.Web.HttpContext The HttpContext instance for the current request
sessionId string The session identifier.
item System.Web.SessionState.SessionStateStoreData The current session values to be stored
lockId object The lock identifier for the current request.
newItem bool If true, a new item is inserted into the store. Otherwise, the existing item in /// the data store is updated with the supplied values, and any lock on the data is released.
return void

SetItemExpireCallback() public method

Takes as input a delegate that references the Session_OnEnd event defined in the Global.asax file. If the session-state store provider supports the Session_OnEnd event, a local reference to the SessionStateItemExpireCallback parameter is set and the method returns true; otherwise, the method returns false.
public SetItemExpireCallback ( SessionStateItemExpireCallback expireCallback ) : bool
expireCallback SessionStateItemExpireCallback A callback.
return bool