KingNET.PageLib/Cache/CachesFileMonitor.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.IO;
using KingNET.PageLib.Helper;
namespace KingNET.PageLib.Cache
{
/// <summary>
///
/// </summary>
public class CachesFileMonitor
{
private static string path = ConfigHelper.ConfigPath + "cache.config";
/// <summary>
/// 程序刚加载时cache.config文件修改时间
/// </summary>
private static DateTime cachefileoldchange;
/// <summary>
/// 最新general.config文件修改时间
/// </summary>
public static DateTime cachefilenewchange;
private static object cachelockHelper = new object();
/// <summary>
/// 静态构造函数
/// </summary>
static CachesFileMonitor()
{
if (!System.IO.File.Exists(path))
{
string content = "<?xml version=\"1.0\" standalone=\"yes\"?>\r\n";
content += "<cachetableremove>\r\n<table1 xpath=\"example\" removedatetime=\"2007-1-9 17:36:23\" />\r\n</cachetableremove>";
using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
{
Byte[] info = System.Text.Encoding.UTF8.GetBytes(content);
fs.Write(info, 0, info.Length);
fs.Close();
}
}
cachefileoldchange = System.IO.File.GetLastWriteTime(path);
}
/// <summary>
/// 检查和移除缓存
/// </summary>
/// <param name="instance"></param>
/// <returns></returns>
public static KingNETCache CheckAndRemoveCache(KingNETCache instance)//
{
//当程序运行中cache.config发生变化时则对缓存对象做删除的操作
cachefilenewchange = System.IO.File.GetLastWriteTime(path);
if (cachefileoldchange != cachefilenewchange)
{
lock (cachelockHelper)
{
后面还有 76 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。