Beispiel #1
0
        private CacheItem GetAmdCacheItem(uint register, CacheLevels cacheLevels, CacheType cacheType)
        {
            var l1DataSize          = register >> 24;
            var waysOfAssociativity = GetAssociativity((byte)(register >> 16 & 0xFF));
            var lineSize            = register & 0xFF;

            return(new CacheItem()
            {
                Level = cacheLevels,
                LineSize = (ushort)lineSize,
                SizeKbytes = l1DataSize,
                CacheType = cacheType,
                Associativity = waysOfAssociativity
            });
        }
Beispiel #2
0
 /// <summary>
 /// If the cache exists this function will preform a comparison of the two IComparable objects to determine if the cache is stale. If the cache is stale it will then fire 
 /// the FetchDataEvent to fetch the new data. This overload has the data and cache dependency passed directly to it, and functions more like a conditional cache Add()
 /// function.
 /// </summary>
 /// <param name="UniqueCacheName">A unique name that will be used as the key for the cache value.</param>
 /// <param name="CacheLength">The Lenght of time that the cache is stored.</param>
 /// <param name="CompareType">The type of comparison that will result in the cache needing to be updated. 
 /// <example>If the CompareType is Equal then if CachedIComparable.CompareTo(EventDrivenIComparable) = 0 that cache will be updated.</example>
 /// </param>
 /// <param name="ValueToCache">The value to be cached.</param>
 /// <param name="CacheDependency">A value that will be used to determine in the cache should be updated.</param>
 /// <param name="CacheUsage">How the cache should be used.</param>
 /// <returns></returns>
 public object ManageCache(string UniqueCacheName, int CacheLength, ComparisonType CompareType, object ValueToCache, IComparable CacheDependency, CacheLevels CacheUsage)
 {
     string DataName = NameSpaceAugment + UniqueCacheName + DataAugment, TimeName = NameSpaceAugment + UniqueCacheName + DependAugment;
     object CacheData = SiteSettings.ContextData.Cache[DataName];
     _CompareValue = CacheDependency;
     IComparable CacheDepend = (IComparable)SiteSettings.ContextData.Cache[TimeName];
     if (CacheData == null || CacheUsage != TotalTech.CMS.Data.CacheLevels.UseCache || (CacheDepend != null && CompareCacheDependency(CacheDepend, _CompareValue, CompareType))) {
         _DataObject = ValueToCache;
         _CompareValue = CacheDependency;
         if (CacheData != null) {//remove old cache values
             SiteSettings.ContextData.Cache.Remove(DataName);
             SiteSettings.ContextData.Cache.Remove(TimeName);
         }
         if (CacheUsage != TotalTech.CMS.Data.CacheLevels.NoCache) {//store the new value in the cache if the user wants too
             SiteSettings.ContextData.Cache.Add(DataName, _DataObject, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(CacheLength), System.Web.Caching.CacheItemPriority.Default, null);
             SiteSettings.ContextData.Cache.Add(TimeName, _CompareValue, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(CacheLength), System.Web.Caching.CacheItemPriority.Default, null);
         }
     }
     else if (CacheData != null) //we can use the old cache value
         _DataObject = SiteSettings.ContextData.Cache[DataName];
     return _DataObject;
 }
 public void Read()
 {
     //TODO need to play with this a bit more
     var array  = new OneLineStruct[CacheSize];
     var result = CacheLevels.ReadStruct(array);
 }