public void Refresh(string removedKey, object expiredValue, CacheItemRemovedReason removalReason)
        {
            var cacheManager = EnterpriseLibraryContainer.Current.GetInstance<ICacheManager>();
            var fileContents = File.ReadAllText(_filename);
            var refreshAction = new FileRefreshAction(_filename);
            var expiration = new FileDependency(_filename);

            cacheManager.Add(removedKey, fileContents, CacheItemPriority.Normal, refreshAction, expiration);
        }
Пример #2
0
 /// <summary>
 /// 文件依赖
 /// </summary>
 /// <param name="objId"></param>
 /// <param name="o"></param>
 /// <param name="files"></param>
 public void AddObjectWithFileChange(string objId, object o, string files)
 {
     if (objId == null || objId.Length == 0 || o == null)
     {
         return;
     }
     FileDependency _fileDep = new FileDependency(files);
     CacheFactory.GetCacheManager().Add(objId, o, CacheItemPriority.High, null, _fileDep);
 }
Пример #3
0
 public FileDependency(string fullFileName)
 {
     expiration = new EntCaching.FileDependency(fullFileName);
 }
Пример #4
0
 /// <summary>
 /// 把值放到缓存里,并指定依赖文件的路径
 /// </summary>
 /// <param name="key">键</param>
 /// <param name="value">值</param>
 /// <param name="path">依赖文件的路径</param>
 public static void SetCacheItem(string key, object value, string path)
 {
     ICacheManager cache = CacheFactory.GetCacheManager("CacheManager");
     FileDependency fd = new FileDependency(path);
     cache.Add(key, value, CacheItemPriority.Normal, null, new ICacheItemExpiration[] { fd });
 }