internal static CacheInternal Create()
 {
     CacheInternal internal2;
     CacheCommon cacheCommon = new CacheCommon();
     int numSingleCaches = 0;
     uint numProcessCPUs = (uint) SystemInfo.GetNumProcessCPUs();
     numSingleCaches = 1;
     numProcessCPUs--;
     while (numProcessCPUs > 0)
     {
         numSingleCaches = numSingleCaches << 1;
         numProcessCPUs = numProcessCPUs >> 1;
     }
     if (numSingleCaches == 1)
     {
         internal2 = new CacheSingle(cacheCommon, null, 0);
     }
     else
     {
         internal2 = new CacheMultiple(cacheCommon, numSingleCaches);
     }
     cacheCommon.SetCacheInternal(internal2);
     cacheCommon.ResetFromConfigSettings();
     return internal2;
 }
Exemple #2
0
        internal static CacheInternal Create()
        {
            CacheInternal internal2;
            CacheCommon   cacheCommon     = new CacheCommon();
            int           numSingleCaches = 0;
            uint          numProcessCPUs  = (uint)SystemInfo.GetNumProcessCPUs();

            numSingleCaches = 1;
            numProcessCPUs--;
            while (numProcessCPUs > 0)
            {
                numSingleCaches = numSingleCaches << 1;
                numProcessCPUs  = numProcessCPUs >> 1;
            }
            if (numSingleCaches == 1)
            {
                internal2 = new CacheSingle(cacheCommon, null, 0);
            }
            else
            {
                internal2 = new CacheMultiple(cacheCommon, numSingleCaches);
            }
            cacheCommon.SetCacheInternal(internal2);
            cacheCommon.ResetFromConfigSettings();
            return(internal2);
        }
 internal CacheSingle(CacheCommon cacheCommon, CacheMultiple cacheMultiple, int iSubCache) : base(cacheCommon)
 {
     this._cacheMultiple = cacheMultiple;
     this._iSubCache     = iSubCache;
     this._entries       = new Hashtable(CacheKeyComparer.GetInstance());
     this._expires       = new CacheExpires(this);
     this._usage         = new CacheUsage(this);
     this._lock          = new object();
     this._insertBlock   = new ManualResetEvent(true);
 }
 internal CacheSingle(CacheCommon cacheCommon, CacheMultiple cacheMultiple, int iSubCache) : base(cacheCommon)
 {
     this._cacheMultiple = cacheMultiple;
     this._iSubCache = iSubCache;
     this._entries = new Hashtable(CacheKeyComparer.GetInstance());
     this._expires = new CacheExpires(this);
     this._usage = new CacheUsage(this);
     this._lock = new object();
     this._insertBlock = new ManualResetEvent(true);
 }
Exemple #5
0
        // common implementation
        static internal CacheInternal Create() {
            CacheCommon cacheCommon = new CacheCommon();
            CacheInternal cacheInternal;
#if USE_MEMORY_CACHE
            if (UseMemoryCache) {
                cacheInternal = new MemCache(cacheCommon);
                cacheCommon.AddSRefTarget(cacheInternal);
            }
            else {
#endif
                int numSubCaches = 0;
                uint numCPUs = (uint) SystemInfo.GetNumProcessCPUs();
                // the number of subcaches is the minimal power of 2 greater
                // than or equal to the number of cpus
                numSubCaches = 1;
                numCPUs -= 1;
                while (numCPUs > 0) {
                    numSubCaches <<= 1;
                    numCPUs >>= 1;
                }
                if (numSubCaches == 1) {
                    cacheInternal = new CacheSingle(cacheCommon, null, 0);
                }
                else {
                    cacheInternal = new CacheMultiple(cacheCommon, numSubCaches);
                }
#if USE_MEMORY_CACHE
            }
#endif
            cacheCommon.SetCacheInternal(cacheInternal);
            cacheCommon.ResetFromConfigSettings();

            return cacheInternal;
        }
Exemple #6
0
        CacheMultiple       _cacheMultiple;     /* the CacheMultiple containing this cache */

        /*
         * Constructs a new Cache.
         */
        internal CacheSingle(CacheCommon cacheCommon, CacheMultiple cacheMultiple, int iSubCache) : base(cacheCommon) {
            _cacheMultiple = cacheMultiple;
            _iSubCache = iSubCache;
            _entries = new Hashtable(CacheKeyComparer.GetInstance());
            _expires = new CacheExpires(this);
            _usage = new CacheUsage(this);
            _lock = new object();
            _insertBlock = new ManualResetEvent(true);
            cacheCommon.AddSRefTarget(new { _entries, _expires, _usage });
        }