Ejemplo n.º 1
0
        public void Slide(bool async = false)
        {
            var prefix = GetSessionItemKey(string.Empty);
            var expire = UnlockedExtensions.GetNextTimeout(configuration.SessionTimeout);

            SlideInternal(prefix, expire, async);
        }
Ejemplo n.º 2
0
        public bool Set(string key, object value, TimeSpan?expireTime = null, bool async = false)
        {
            var expire = expireTime.HasValue
                ? expireTime.Value
                : UnlockedExtensions.GetNextTimeout(configuration.SessionTimeout);
            var redisKey = GetSessionItemKey(key);
            var result   = SetInternal(redisKey, value, expire, async);

            return(result);
        }
Ejemplo n.º 3
0
        public override void EndRequest(System.Web.HttpContext context)
        {
            if (UnlockedStateStoreConfiguration.Instance.Disabled)
            {
                return;
            }

            //var session = filterContext.HttpContext.GetContextItem(UNLOCKED_STATE_OBJECT_KEY);
            if (Store.Items.Count > 0)
            {
                //filterContext.StartSessionIfNew();
                //var store = (IUnlockedStateStore)filterContext.GetContextItem(UNLOCKED_STATE_STORE_KEY);
                // store.UpdateContext();
                var expire = UnlockedExtensions.GetNextTimeout(Store.Configuration.SessionTimeout);
                Store.Set(UnlockedExtensions.UNLOCKED_STATE_STORE_KEY, Store.Items, expire);
            }
            //base.EndRequest(context);
            //UnlockedStateStore.Dispose();
        }
Ejemplo n.º 4
0
        protected object GetInternal(string key, bool slide = true, bool slideAsync = true, bool preferSlave = true)
        {
            var redisDatabase = GetRedisDatabase();
            var flag          = CommandFlags.None;

            if (preferSlave)
            {
                flag = CommandFlags.PreferSlave;
            }
            var data   = redisDatabase.StringGet(key, flag);
            var result = StateBinarySerializer.Deserialize(data);

            if (slide)
            {
                var expire = UnlockedExtensions.GetNextTimeout(configuration.SessionTimeout);
                var prefix = GetSessionItemPrefix();
                SlideInternal(prefix, expire, slideAsync);
            }
            return(result);
        }