Ejemplo n.º 1
0
        static TimerHelper()
        {
            //Redis dump.rdb文件监测
            var path = ConfigUtils.GetSetting("RedisRdbPath", string.Empty);

            if (!string.IsNullOrEmpty(path))
            {
                if (File.Exists(path))
                {
                    _redisRdbPath = path;
                }
                else
                {
                    DataSyncQueueManager.BgSave();
                    if (File.Exists(path))
                    {
                        _redisRdbPath = path;
                    }
                }
            }
            if (string.IsNullOrEmpty(_redisRdbPath))
            {
                TraceLog.WriteError("Redis dump.rdb 文件未在监测中...");
            }
            else
            {
                DataSyncQueueManager.BgSave();
                Console.WriteLine("Redis {0} 文件成功监测中...", _redisRdbPath);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Redis rdb是否正常
        /// </summary>
        /// <returns></returns>
        public static bool isRedisRdbWork()
        {
            if (!string.IsNullOrEmpty(_redisRdbPath))
            {
                var fi        = new System.IO.FileInfo(_redisRdbPath);
                var totalSecs = (DateTime.Now - fi.LastWriteTime).TotalSeconds;
                if (totalSecs > 600)
                {
                    return(false);
                }
                else if (totalSecs >= 300)
                {
                    DataSyncQueueManager.BgSave();
                }
            }

            return(true);
        }