Redis Learning Note ~stackexchange.redis implementation of distributed session

Source: Internet
Author: User
Tags redis server

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

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.