Ejemplo n.º 1
0
 internal void Renew(Client client, int clientLeaseTime)
 {
     if (client.ClientLeaseTime == clientLeaseTime)
     {
         //Keep the client in the cache.
         HttpRuntime.Cache.Get(client.Id);
         return;
     }
     lock (this.SyncRoot)
     {
         if (client.ClientLeaseTime < clientLeaseTime)
         {
             log.Debug(__Res.GetString(__Res.Client_Lease, client.Id, client.ClientLeaseTime, clientLeaseTime));
             client.SetClientLeaseTime(clientLeaseTime);
         }
         if (clientLeaseTime == 0)
         {
             log.Debug(__Res.GetString(__Res.Client_Lease, client.Id, client.ClientLeaseTime, clientLeaseTime));
             client.SetClientLeaseTime(0);
         }
         if (client.ClientLeaseTime != 0)
         {
             HttpRuntime.Cache.Remove(client.Id);
             // Add the FlexClient to the Cache with the expiration item
             HttpRuntime.Cache.Insert(client.Id, client, null,
                                      Cache.NoAbsoluteExpiration,
                                      new TimeSpan(0, client.ClientLeaseTime, 0),
                                      CacheItemPriority.NotRemovable, new CacheItemRemovedCallback(this.RemovedCallback));
         }
         else
         {
             HttpRuntime.Cache.Remove(client.Id);
         }
     }
 }
Ejemplo n.º 2
0
 internal void Renew(Client client, int clientLeaseTime)
 {
     lock (_objLock)
     {
         this._clients[client.Id] = client;
         HttpRuntime.Cache.Remove(client.Id);
         if (client.ClientLeaseTime < clientLeaseTime)
         {
             client.SetClientLeaseTime(clientLeaseTime);
             log.Debug(string.Format("Renew Client {0} clientLeaseTime {1}", client.Id, clientLeaseTime));
         }
         if (clientLeaseTime == 0)
         {
             client.SetClientLeaseTime(0);
             log.Debug(string.Format("Renew Client {0} clientLeaseTime {1}", client.Id, clientLeaseTime));
         }
         if (client.ClientLeaseTime != 0)
         {
             HttpRuntime.Cache.Insert(client.Id, client, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, client.ClientLeaseTime, 0), CacheItemPriority.NotRemovable, new CacheItemRemovedCallback(this.RemovedCallback));
         }
     }
 }
Ejemplo n.º 3
0
 internal void Renew(Client client, int clientLeaseTime)
 {
     if (client.ClientLeaseTime == clientLeaseTime)
     {
         //Keep the client in the cache.
         HttpRuntime.Cache.Get(client.Id);
         return;
     }
     lock (this.SyncRoot)
     {
         if (client.ClientLeaseTime < clientLeaseTime)
         {
             log.Debug(__Res.GetString(__Res.Client_Lease, client.Id, client.ClientLeaseTime, clientLeaseTime));
             client.SetClientLeaseTime(clientLeaseTime);
         }
         if (clientLeaseTime == 0)
         {
             log.Debug(__Res.GetString(__Res.Client_Lease, client.Id, client.ClientLeaseTime, clientLeaseTime));
             client.SetClientLeaseTime(0);
         }
         if (client.ClientLeaseTime != 0)
         {
             HttpRuntime.Cache.Remove(client.Id);
             // Add the FlexClient to the Cache with the expiration item
             HttpRuntime.Cache.Insert(client.Id, client, null,
                 Cache.NoAbsoluteExpiration,
                 new TimeSpan(0, client.ClientLeaseTime, 0),
                 CacheItemPriority.NotRemovable, new CacheItemRemovedCallback(this.RemovedCallback));
         }
         else
             HttpRuntime.Cache.Remove(client.Id);
     }
 }