コード例 #1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            this.clientManager = new PooledRedisClientManager("localhost:6379");

            RedisSessionStateStoreProvider.SetClientManager(this.clientManager);
        }
        public void Initialize_with_specified_clients_manager_should_not_manage_lifetime()
        {
            try
            {
                var clientManager = new Mock <IRedisClientsManager>();
                RedisSessionStateStoreProvider.SetClientManager(clientManager.Object);
                var provider = new RedisSessionStateStoreProvider();
                provider.Initialize(KeyName, new NameValueCollection());

                Assert.AreSame(clientManager.Object, provider.ClientManager);

                provider.Dispose();

                clientManager.Verify(m => m.Dispose(), Times.Never());
            }
            finally
            {
                RedisSessionStateStoreProvider.ResetClientManager();
            }
        }
コード例 #3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            this.clientManager = new PooledRedisClientManager("localhost:6379");
            RedisSessionStateStoreProvider.SetClientManager(this.clientManager);
            RedisSessionStateStoreProvider.SetOptions(new RedisSessionStateStoreOptions()
            {
                KeySeparator = ":",
                OnDistributedLockNotAcquired = sessionId =>
                {
                    Console.WriteLine("Session \"{0}\" could not establish distributed lock. " +
                                      "This most likely means you have to increase the " +
                                      "DistributedLockAcquireSeconds/DistributedLockTimeoutSeconds.", sessionId);
                }
            });
        }