/// <summary> /// 分布式缓存客户端开启 /// </summary> public static void Start() { //_cacheNameList = DistributedCacheManage.GetCacheNameList();//本节点的客户端缓存名列表和服务端缓存列表必须一致 //客户端订阅分布式缓存 SubscribeServiceObject ssObject = new SubscribeServiceObject(); ssObject.publishServiceName = publishServiceName; ssObject.ProcessService = ((ClientLink _clientLink) => { List <CacheIdentify> ciList = DistributedCacheClient.GetCacheIdentifyList(); //获取本地缓存索引 List <CacheObject> coList = _clientLink.GetDistributedCacheData(ciList); //比对上级中间件缓存,返回差异的缓存对象 if (coList.Count > 0) { //调试 //foreach (var i in coList) //{ // if(i.cachename== "mnodeplugin") // { // foreach(var n in i.cacheValue) // { // CoreFrame.Common.MiddlewareLogHelper.WriterLog(n.key); // CoreFrame.Common.MiddlewareLogHelper.WriterLog(n.value); // } // } //} DistributedCacheClient.SetCacheObjectList(coList);//将差异的缓存对象同步到本节点中间件 } }); SubscriberManager.Subscribe(ssObject); }
private static Object syncObj = new Object(); //定义一个静态对象用于线程部份代码块的锁定,用于lock操作 public static void Start() { CreateSuperClient(); //初始化连接池,默认10分钟清理连接 ClientLinkPoolCache.Init(true, 100, 30, 600, "dataclient", 30); if (superClientLink != null) { superClientLink.ReConnectionAction = (() => { SubscriberManager.ReSubscribeAll();//重新订阅 }); } }
private static string publishServiceName = "UpgradeManage";//订阅服务名 /// <summary> /// 分布式缓存客户端开启 /// </summary> public static void Start() { rootpath = AppGlobal.AppRootPath + "FileStore\\"; //创建客户端升级包目录 if (!Directory.Exists(rootpath + clientupgrade)) { Directory.CreateDirectory(rootpath + clientupgrade); } //创建Web程序升级包目录 if (!Directory.Exists(rootpath + webupgrade)) { Directory.CreateDirectory(rootpath + webupgrade); } //创建中间件程序升级包目录 if (!Directory.Exists(rootpath + mnodeupgrade)) { Directory.CreateDirectory(rootpath + mnodeupgrade); } //创建插件服务程序升级包目录 if (!Directory.Exists(rootpath + pluginupgrade)) { Directory.CreateDirectory(rootpath + pluginupgrade); } //客户端订阅分布式缓存 SubscribeServiceObject ssObject = new SubscribeServiceObject(); ssObject.publishServiceName = publishServiceName; ssObject.ProcessService = ((ClientLink _clientLink) => { //DownLoadUpgrade(clientupgrade + "update.xml", clientupgrade + "update.zip", _clientLink); //DownLoadUpgrade(webupgrade + "update.xml", webupgrade + "update.zip", _clientLink); //DownLoadUpgrade(mnodeupgrade + "update.xml", mnodeupgrade + "update.zip", _clientLink); //下载插件 //DownLoadPlugin(_clientLink); //UpgradeManage.UpdateUpgrade();//通知下级中间件升级 }); SubscriberManager.Subscribe(ssObject); }
public static void Stop() { //客户端取消订阅分布式缓存 SubscriberManager.UnSubscribe(publishServiceName); }