Back to Catalog
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
<sessionstate mode="Custom"Customprovider="Mysessionstatestore"timeout=" -"> <providers> <!--either use'connectionString'and provide all parameters as stringOR use'Host','Port','AccessKey','SSL','Connectiontimeoutinmilliseconds'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="false"[true|false] throwOnError="true"[true|false] Retrytimeoutinmilliseconds=" the"[number] databaseId="0"[number] ApplicationName=""[String] Connectiontimeoutinmilliseconds=" the"[number] Operationtimeoutinmilliseconds=" +"[number] connectionString="<valid Stackexchange.redis Connection string>"[String] Loggingclassname="<assembly qualified class name that contains logging method specified below>"[String] Loggingmethodname="<logging method 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.>"[String]/>--<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,
Thank my VIP group of buddies to raise this issue, and the session timeout set to solve.
Back to Catalog
Redis Learning Note ~stackexchange.redis implementation of distributed session