Redis的支持ASP.NET SessionState会提供商 [英] Redis backed ASP.NET SessionState provider
问题描述
我目前正在开发由使用Redis的支持Booksleeve一个ASP.NET SessionState会定义提供。 Redis的似乎是一个非常适合SessionState会(如果你必须使用它),因为:
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:
- Redis的可持久保存像一个RDBMS,但它的速度要快得多。
- 键/值数据存储更符合SessionState会的界面。
- 因为数据不存储在进程(如默认会议提供商),SessionState会能活出Web服务器重启,死机等。
- Redis是容易如果变成需要横向碎片。
所以,我想知道如果因为我们(我公司)正在考虑在GitHub开源它,这将是有用的人。思考?
So, I'm wondering if this will be useful to anyone since we (my company) are considering open sourcing it on GitHub. Thoughts?
我没有发布这个昨天的第一个版本:<一href=\"https://github.com/angieslist/AL-Redis/blob/master/AngiesList.Redis/RedisSessionStateStore.cs\">https://github.com/angieslist/AL-Redis/blob/master/AngiesList.Redis/RedisSessionStateStore.cs
I did release a first version of this yesterday: https://github.com/angieslist/AL-Redis/blob/master/AngiesList.Redis/RedisSessionStateStore.cs
推荐答案
我创建了一个Redis的基于 SessionStateStoreProvider
的的可以在GitHub上使用 ServiceStatck.Redis
作为客户端(而非Booksleeve)被发现。
I've created a Redis-based SessionStateStoreProvider
that can be found on GitHub using ServiceStatck.Redis
as the client (rather than Booksleeve).
它可以通过的NuGet安装与安装封装Harbour.RedisSessionStateStore
。
It can be installed via NuGet with Install-Package Harbour.RedisSessionStateStore
.
我发现@ NathanD的做法一些怪癖。我在执行,锁存储的与的会话值,而不是单独的密钥(往返Redis的更少)。此外,因为它使用 ServiceStack.Redis
,也可以使用连接池。
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.
最后,它的测试。这是我最大的关闭从@ NathanD的做法。没有任何的真正的方式知道如果它的工作,而无需通过每个用例手动运行。
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.
这篇关于Redis的支持ASP.NET SessionState会提供商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!