I'm currently developing an ASP.NET SessionState custom provider that is backed by Redis using Booksleeve. Redis seemed like a perfect fit for SessionState (if you must use it) because:
So, I'm wondering if this will be useful to anyone since we (my company) are considering open sourcing it on GitHub. Thoughts?
I did release a first version of this yesterday: https://github.com/angieslist/AL-Redis/blob/master/AngiesList.Redis/RedisSessionStateStore.cs
I've created a Redis-based SessionStateStoreProvider
that can be found on GitHub using ServiceStatck.Redis
as the client (rather than Booksleeve).
It can be installed via NuGet with Install-Package Harbour.RedisSessionStateStore
.
I found a few quirks with @NathanD's approach. In my implementation, locks are stored with the session value rather than in a separate key (less round trips to Redis). Additionally, because it uses ServiceStack.Redis
, it can used pooled connections.
Finally, it's tested. This was my biggest turn off from @NathanD's approach. There was no way of actually knowing if it worked without running through every use case manually.
Not only would it be useful, but I strongly consider you look closely at the Redis' Hash datatype if you plan to go down this road. In our application the session is basically a small collection of keys and values (i.e.: {user_id: 7, default_timezone: 'America/Chicago', ...}
) with the entire user session stored under in a single Redis hash.
Not only does using Hash simplify mapping the data if your session data is similar, but Redis uses space much more efficiently with this approach.
Our app is in ruby, but you might still find some use from what we wrote.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With