Example #1
0
        /// <summary>
        /// Recupera o conjunto de chaves de cache informado.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="timeout"></param>
        /// <returns></returns>
        internal static object[] GetKeyset(CacheBase cache, int timeout)
        {
            ulong num = 0;

            object[] objArray = null;
            cache.Sync.AcquireWriterLock(timeout);
            try
            {
                if (!cache.Sync.IsWriterLockHeld || (cache.Count < 1))
                {
                    return(objArray);
                }
                objArray = new object[cache.Count];
                IEnumerator enumerator = cache.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    num++;
                    DictionaryEntry current = (DictionaryEntry)enumerator.Current;
                    objArray[(int)((IntPtr)num)] = current.Key;
                }
            }
            finally
            {
                cache.Sync.ReleaseWriterLock();
            }
            return(objArray);
        }
Example #2
0
 public override void Dispose()
 {
     if (_cache != null)
     {
         _cache.Dispose();
         _cache = null;
     }
     base.Dispose();
 }
Example #3
0
 public static CacheBase Synchronized(CacheBase cache)
 {
     return(new CacheSyncWrapper(cache));
 }