For a multi-web environment is now necessary, it is difficult to imagine a Web server facing millions of concurrent response, so we need multiple Web server cluster to alleviate this high concurrency, high throughput scenarios, and for multi-web scenarios there will be a problem, that is, session storage problems, If a user logged in, a state information stored in the current Web server session, and you request other pages, it is likely to be routed to another server, then, the session is lost, and for this situation, someone put redis this storage middleware think up, It is encapsulated, and there is today a Redis-based session sharing mechanism.
The following is the installation method
1 Installing Redis cache Stackexchange.redis with NuGet
2 Installing the Redissession service with NuGet Redissessionstateprovider
3 after adding redissession from NuGet, it writes the following in your config file, mainly the session persistence setting
<SessionStateMode="Custom"Customprovider="Mysessionstatestore"timeout=">"<Providers><!--either use ' connectionString ' and provide-parameters as String OR use ' host ', ' Port ', ' AccessKey ', ' SSL ', ' Connect Iontimeoutinmilliseconds ' and ' operationtimeoutinmilliseconds '. -<!--' throwOnError ', ' retrytimeoutinmilliseconds ', ' databaseId ' and ' applicationname ' can is used with both options. -<!--<add name= "mysessionstatestore" host = "127.0.0.1" [string] Port = "" [number] AccessKey = "" [string] SSL = "F Alse "[true|false] throwOnError =" true "[true|false] retrytimeoutinmilliseconds =" "[number] DatabaseId =" 0 "[Numbe r] ApplicationName = "" [String] connectiontimeoutinmilliseconds = "["] [number] Operationtimeoutinmilliseconds = "1000 "[number] connectionString =" <valid Stackexchange.redis connection String> "[string] loggingclassname =" <asse Mbly qualified class name that contains logging method specified below> "[String] loggingmethodname =" <logging meth OD should is defined in Loggingclass. It should is public, static, does not take any parameters and should has a return type of system.io.textwriter.> "[Str ing]/>--<add name= "mysessionstatestore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="127.0.0.1" accesskey= "" ssl="false"/> </providers> </ sessionstate>
4 download is a new version of the Redis server, can be Windows edition, I use 2.6.13, the lower version of Redis will be the eval command unrecognized problem
5 processing complete, you can test your session, the default expiration time is 1200 seconds
Note that the timeout in the above sessionstate is set to the session timeout, it is also used for Redis storage, the following is the presence of Redis in the session,
Transferred from: Http://www.tuicool.com/articles/UbYJbyq
Redis Learning Note ~stackexchange.redis implementation of distributed session