Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobody <nobody@localhost>2002-08-21 14:08:33 +0400
committernobody <nobody@localhost>2002-08-21 14:08:33 +0400
commit4e4824afab6cd0f9f0d71aa6baeddb7bee74f8c4 (patch)
tree4f2f12d32cc0fbc38f5ae17dd88b54f7f7d4773b /mcs/class/System.Web/System.Web.Caching/CacheExpires.cs
parent5a04c908e923e4d919c9c0aed1129f8416adb6cc (diff)
This commit was manufactured by cvs2svn to create branch 'SAVANNAH_CVS'.RHYS_20020821
svn path=/branches/SAVANNAH_CVS/mcs/; revision=6844
Diffstat (limited to 'mcs/class/System.Web/System.Web.Caching/CacheExpires.cs')
-rw-r--r--mcs/class/System.Web/System.Web.Caching/CacheExpires.cs145
1 files changed, 0 insertions, 145 deletions
diff --git a/mcs/class/System.Web/System.Web.Caching/CacheExpires.cs b/mcs/class/System.Web/System.Web.Caching/CacheExpires.cs
deleted file mode 100644
index a58eb5c1e69..00000000000
--- a/mcs/class/System.Web/System.Web.Caching/CacheExpires.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-//
-// System.Web.Caching
-//
-// Author:
-// Patrik Torstensson (Patrik.Torstensson@labs2.com)
-//
-// (C) Copyright Patrik Torstensson, 2001
-//
-namespace System.Web.Caching
-{
- /// <summary>
- /// Class responsible for handling time based flushing of entries in the cache. The class creates
- /// and manages 60 buckets each holding every item that expires that minute. The bucket calculated
- /// for an entry is one minute more than the timeout just to make sure that the item end up in the
- /// bucket where it should be flushed.
- /// </summary>
- public class CacheExpires : System.IDisposable
- {
- static int _intFlush;
- static long _ticksPerBucket = 600000000;
- static long _ticksPerCycle = _ticksPerBucket * 60;
-
- private ExpiresBucket[] _arrBuckets;
- private System.Threading.Timer _objTimer;
- private Cache _objManager;
-
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="objManager">The cache manager, used when flushing items in a bucket.</param>
- public CacheExpires(Cache objManager)
- {
- _objManager = objManager;
- Initialize();
- }
-
- /// <summary>
- /// Initializes the class.
- /// </summary>
- private void Initialize()
- {
- // Create one bucket per minute
- _arrBuckets = new ExpiresBucket[60];
-
- byte bytePos = 0;
- do
- {
- _arrBuckets[bytePos] = new ExpiresBucket(bytePos, _objManager);
- bytePos++;
- } while (bytePos < 60);
-
- // GC Bucket controller
- _intFlush = System.DateTime.Now.Minute - 1;
- _objTimer = new System.Threading.Timer(new System.Threading.TimerCallback(GarbageCleanup), null, 10000, 60000);
- }
-
- /// <summary>
- /// Adds a Cache entry to the correct flush bucket.
- /// </summary>
- /// <param name="objEntry">Cache entry to add.</param>
- public void Add(CacheEntry objEntry)
- {
- long ticksNow = System.DateTime.Now.Ticks;
-
- lock(this)
- {
- // If the entry doesn't have a expires time we assume that the entry is due to expire now.
- if (objEntry.Expires == 0)
- {
- objEntry.Expires = ticksNow;
- }
-
- _arrBuckets[GetHashBucket(objEntry.Expires)].Add(objEntry);
- }
- }
-
- public void Remove(CacheEntry objEntry)
- {
- long ticksNow = System.DateTime.Now.Ticks;
-
- lock(this)
- {
- // If the entry doesn't have a expires time we assume that the entry is due to expire now.
- if (objEntry.Expires == 0)
- {
- objEntry.Expires = ticksNow;
- }
-
- _arrBuckets[GetHashBucket(objEntry.Expires)].Remove(objEntry);
- }
- }
-
- public void Update(CacheEntry objEntry, long ticksExpires)
- {
- long ticksNow = System.DateTime.Now.Ticks;
-
- lock(this)
- {
- // If the entry doesn't have a expires time we assume that the entry is due to expire now.
- if (objEntry.Expires == 0)
- {
- objEntry.Expires = ticksNow;
- }
-
- _arrBuckets[GetHashBucket(objEntry.Expires)].Update(objEntry, ticksExpires);
- }
- }
-
- public void GarbageCleanup(object State)
- {
- ExpiresBucket objBucket;
-
- lock(this)
- {
- // Do cleanup of the bucket
- objBucket = _arrBuckets[(++_intFlush) % 60];
- }
-
- // Flush expired items in the current bucket (defined by _intFlush)
- objBucket.FlushExpiredItems();
- }
-
- private int GetHashBucket(long ticks)
- {
- // Get bucket to add expire item into, add one minute to the bucket just to make sure that we get it in the bucket gc
- return (int) (((((ticks + 60000) % _ticksPerCycle) / _ticksPerBucket) + 1) % 60);
- }
-
- /// <summary>
- /// Called by the cache for cleanup.
- /// </summary>
- public void Dispose()
- {
- lock(this)
- {
- // Cleanup the internal timer
- if (_objTimer != null)
- {
- _objTimer.Dispose();
- _objTimer = null;
- }
- }
- }
- }
-}