protected override void CreateCacheHierarchy(CacheCapacity[] cacheCapacityList) { if (cacheCapacityList.Length != 2) { throw new Exception("CapacityList doesn't match SchedulerType"); } RAMCache ram = new RAMCache(CacheMediumType.RAM.ToString(), cacheCapacityList[0], this.logger); FileCache file = new FileCache(CacheMediumType.File.ToString(), cacheCapacityList[1], this.logger); ram.PreviousCacheMedium = null; ram.NextCacheMedium = file; file.PreviousCacheMedium = ram; file.NextCacheMedium = null; this.mediums.Add(ram); this.mediums.Add(file); if (this.logger != null) { this.logger.Log("First medium is RAM, second medum is File.", Category.Debug, Priority.Low); } }
public MediumConfiguration(CacheMediumType type, CacheCapacity capacity, IReplacementAlgorithm algorithm) { this.type = type; this.capacity = capacity; this.algorithm = algorithm; }
public RAMCache(string name, CacheCapacity capacity, ILoggerFacade logger) : base(name, capacity, logger) { // if there is no capacity parameter initialized, do not use cache if (this.Capacity.IsEmpty() == true) { throw new Exception("Cache capacity is not initialized."); } this.cacheDictionary = new Dictionary<CacheKey, CacheValue>(); }
public CacheMediumBase(string name, CacheCapacity capacity, ILoggerFacade logger) { this.logger = logger; if (this.logger != null) { this.logger.Log("Cache medium " + name + " instance is created.", Category.Info, Priority.Medium); } this.Capacity = capacity; this.name = name; this.algorithm = null; this.next = null; this.previous = null; this.algorithmData = new AlgorithmData(); this.rwLock = new object(); }
private static CacheCapacity ParseCacheCapacity(XmlNode node) { XmlAttributeCollection attributes = node.Attributes; if (attributes == null || attributes.Count != 1) { throw new Exception("Capacity element is invalid."); } if (attributes[0].Name == "Type") { CacheCapacity capacity = new CacheCapacity((Primary)Enum.Parse(typeof(Primary), attributes[0].Value)); capacity.Count = long.Parse(node.InnerText); return capacity; } return null; }
public FileCache(string name,CacheCapacity capacity, ILoggerFacade logger) : base(name, capacity, logger) { }
public void UpdateCacheCapacity(CacheCapacity capacity) { this.capacity = capacity; }
protected abstract void CreateCacheHierarchy(CacheCapacity[] cacheCapacityList);