Пример #1
0
        public override void CreateUninitializedItem(System.Web.HttpContext context, string id,
                                                     int timeout)
        {
            DateTime dSetTime = DateTime.Now;

            if (this._bIsDbNone == false)
            {
                #region Setting it in Db
                using (IDbOperations objDb = DbFactory.CreateDbOperations(_strDbType, _strConn))
                {
                    objDb.Add(id, ApplicationName, dSetTime,
                              dSetTime.AddMinutes((double)timeout),
                              dSetTime, 0, timeout, false, null, 1);
                }
                #endregion
            }

            #region Updating item in memcached
            MemcachedHolder objHolder = new MemcachedHolder(
                null, false, dSetTime, 0, 1);

            this._client.Store(StoreMode.Set, id, objHolder, new TimeSpan(0, timeout, 0));

            #endregion
        }
Пример #2
0
        public override void SetAndReleaseItemExclusive(System.Web.HttpContext context,
                                                        string id, SessionStateStoreData item, object lockId, bool newItem)
        {
            if (this._bIsDbNone == false)
            {
                #region Db option
                using (IDbOperations objDb = DbFactory.CreateDbOperations(_strDbType, _strConn))
                {
                    byte[]   objContent = null;
                    DateTime dSetTime   = DateTime.Now;

                    objContent = Common.Serialize((SessionStateItemCollection)item.Items);

                    if (newItem == true)
                    {
                        objDb.Add(id, ApplicationName, dSetTime,
                                  dSetTime.AddMinutes((Double)item.Timeout), dSetTime,
                                  0, item.Timeout, false,
                                  objContent, 0);

                        // Setting it up in memcached
                        MemcachedHolder objHolder = new MemcachedHolder(
                            objContent, false, dSetTime, 0, 0);
                        this._client.Store(StoreMode.Set,
                                           id, objHolder, new TimeSpan(0, item.Timeout, 0));
                    }
                    else
                    {
                        objDb.Update(id, ApplicationName, (int)lockId,
                                     dSetTime.AddMinutes((Double)item.Timeout),
                                     objContent, false);

                        // Setting it up in memcached
                        MemcachedHolder objHolder = new MemcachedHolder(
                            objContent, false, dSetTime, 0, 0);

                        this._client.Store(StoreMode.Set,
                                           id, objHolder, new TimeSpan(0, item.Timeout, 0));
                    }
                }
                #endregion
            }
            else // Just memcached version
            {
                byte[]   objContent = null;
                DateTime dSetTime   = DateTime.Now;

                objContent = Common.Serialize((SessionStateItemCollection)item.Items);

                if (newItem == true)
                {
                    // Setting it up in memcached
                    MemcachedHolder objHolder = new MemcachedHolder(
                        objContent, false, dSetTime, 0, 0);
                    this._client.Store(StoreMode.Set,
                                       id, objHolder, new TimeSpan(0, item.Timeout, 0));
                }
                else
                {
                    // Setting it up in memcached
                    MemcachedHolder objHolder = new MemcachedHolder(
                        objContent, false, dSetTime, 0, 0);

                    this._client.Store(StoreMode.Set,
                                       id, objHolder, new TimeSpan(0, item.Timeout, 0));
                }
            }
        }