Skip to content

A Redis based SessionStateStoreProvider written in C# using ServiceStack.Redis.

Notifications You must be signed in to change notification settings

mattlangis/Harbour.RedisSessionStateStore

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mattlangis: This is a slighly modified version of TheCloudlessSky/Harbour.RedisSessionStateStore.

  • Added support for initialDb in .config file.

Harbour.RedisSessionStateStore

This is a Redis based SessionStateStoreProvider written in C# using ServiceStack.Redis.

Installation

  1. You can either install using NuGet: PM> Install-Package Harbour.RedisSessionStateStore
  2. Or install from source: msbuild .\build\build.proj

Usage

Configure your web.config to use the session state provider:

...
<system.web>
  <sessionState mode="Custom" customProvider="RedisSessionStateProvider">
    <providers>
      <clear />
      <add name="RedisSessionStateProvider" 
           type="Harbour.RedisSessionStateStore.RedisSessionStateStoreProvider" 
           host="localhost:6379" clientType="pooled" />
    </providers>
  </sessionState>
</system.web>
...

This configuration will use a PooledRedisClientManager and use the default host and port (localhost:6379). Alternatively you can use the host attribute to set a custom host/port. If you wish to change the client manager type to BasicRedisClientManager, you can set the clientType="basic".

If you require that a custom IClientsManager be configured (for example if you're using an IoC container or you wish to only have one IClientsManager for your whole application), you can do the following when the application starts:

private IRedisClientsManager clientManager;

protected void Application_Start()
{
    // Or use your IoC container to wire this up.
    this.clientManager = new PooledRedisClientManager("localhost:6379");
    RedisSessionStateStoreProvider.SetClientManager(this.clientManager);
}

protected void Application_End()
{
    this.clientManager.Dispose();
}

About

A Redis based SessionStateStoreProvider written in C# using ServiceStack.Redis.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 97.6%
  • CSS 1.9%
  • Other 0.5%