Redis Learning Note ~stackexchange.redis implementation of distributed session

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.