Giter Club home page Giter Club logo

al-redis's Introduction

AL-Redis (AngiesList.Redis)

The AngiesList.Redis library contains a few useful classes:

  • A high performance Session State HttpModule that can replace the built-in Session module
  • A simple, bucketed Key-Value store

Redis Session State HttpModule (AngiesList.Redis.RedisSessionStateModule)

RedisSessionStateModule is a IHttpModule that can replace ASP.NET's default Session module. It has the following features/differences:

  • Session data is stored in Redis (duh)
  • This module does NOT do the per request locking that the default module does (see: http://msdn.microsoft.com/en-us/library/ms178587.aspx ), which means that multiple request under the same SessionId can be processed concurrently.
  • Session items are stored and accessed independently from items in a Redis Hash. So when session is saved at the end of a request, only the session items that were modified during that request need to be persisted to Redis.

To use with Integrated Pipeline mode: Create a remove then an add in the modules element inside the system.webServer element in your web.config like so:

<modules>
  <remove name="Session" />
	<add name="Session" type="AngiesList.Redis.RedisSessionStateModule, AngiesList.Redis" />
</modules>

For IIS 6 or earlier or Classic Pipeline mode: Do the same except in the httpModules element in the system.web element.


Bucketed Key-Value store (AngiesList.Redis.KeyValueStore)

Example usage:

var tags = KeyValueStore.Bucket("tags");
tags.Set("redis", "The swiss army knife data structure server");

var description = tags.GetStringSync("redis");

You can optionally set an expiration (in seconds) when you use Set:

KeyValueStore.Bucket("contentCache").Set("about_us", "We're awesome!", 600);

There are more getter methods:

  • For binary data (GetRawSync() returns byte[])
  • For whatever type T you want. GetSync returns T and handles the (de)serialization from and to T for you.
  • For callback based async operations, there are asyncronous version of all the Get_ methods. Example:
bigNumbers.Get<Int64>("a_trillion", (num, exc) => {
  if (exc == null) {
    //do something with num
  }
});

TODO:

  • add locking support (like the SQL Server provider), make it optional done.
  • add option to use different serializers
  • create a quick benchmark program

al-redis's People

Contributors

gregmac avatar nathanwdavis avatar

Watchers

 avatar

Forkers

ashelley

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.