• 大小: 3.38M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2024-04-26
  • 语言: C#
  • 标签: Memcached  MEM  监控  进程  

资源简介

监控memcache进程,如果关掉自动重启

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Enyim.Caching;
using Enyim.Caching.Memcached;



namespace WindowsFormsApplication2
{
    /// 
    /// CacheHelper
    /// 

    [Serializable]
    public class CacheHelper
    {
        private static readonly MemcachedClient CacheClient = new MemcachedClient();

        /// 
        /// Retrieve cached item
        /// 

        /// Type of cached item
        /// Name of cached item
        /// Cached item as type
        public static T Set(string key T objectToCache) where T : class
        {
            try
            {
                bool status = false;
                if (Get(key) == null)
                {
                    status = CacheClient.Store(StoreMode.Set key objectToCache);
                }
                else
                {
                    status = CacheClient.Store(StoreMode.Replace key objectToCache);
                }
                if (status == false)
                {
                    return null;
                }
                return objectToCache;
            }
            catch
            {
                return null;
            }
        }
        public static object Set(string key object objectToCache)
        {
            try
            {
                bool status = false;
                if (Get(key) == null)
                {
                    status = CacheClient.Store(StoreMode.Set key objectToCache);
                }
                else
                {
                    status = CacheClient.Store(StoreMode.Replace key objectToCache);
                }
                if (status == false)
                {
                    return null;
                }
                return objectToCache;
            }
            catch
            {
                return null;
            }
        }
        public static bool CAS(string key object objectToCacheulong ver)
        {
            CasResult status;
            try
            {

                status = CacheClient.Cas(StoreMode.Set key objectToCachever);
                return (bool)status.Result;
            }
            catch
            {
                return false;
            }
        }

        /// 
        /// Retrieve cached item
        /// 

        /// Type of cached item
        /// Name of cached item
        /// Cached item as type
        public static T Get(string key) where T : class
        {
            try
            {
                return (T)CacheClient.Get(key);
            }
            catch
            {
                return null;
            }
      

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-01-31 10:31  MemCachedWatch\
     目录           0  2019-01-31 16:33  MemCachedWatch\MemCachedWatch\
     文件        6332  2019-01-23 07:58  MemCachedWatch\MemCachedWatch\CacheHelper.cs
     文件        3750  2019-01-31 16:56  MemCachedWatch\MemCachedWatch\Form1.Designer.cs
     文件        3124  2019-02-01 07:47  MemCachedWatch\MemCachedWatch\Form1.cs
     文件       57565  2019-01-31 16:56  MemCachedWatch\MemCachedWatch\Form1.resx
     文件        4307  2019-01-31 16:44  MemCachedWatch\MemCachedWatch\MemCachedWatch.csproj
     文件         227  2019-01-31 11:05  MemCachedWatch\MemCachedWatch\MemCachedWatch.csproj.user
     文件         495  2019-01-31 10:31  MemCachedWatch\MemCachedWatch\Program.cs
     目录           0  2019-01-31 10:31  MemCachedWatch\MemCachedWatch\Properties\
     文件        1378  2019-01-31 10:31  MemCachedWatch\MemCachedWatch\Properties\AssemblyInfo.cs
     文件        2868  2019-01-31 11:05  MemCachedWatch\MemCachedWatch\Properties\Resources.Designer.cs
     文件        5612  2019-01-31 10:31  MemCachedWatch\MemCachedWatch\Properties\Resources.resx
     文件        1114  2019-01-31 11:05  MemCachedWatch\MemCachedWatch\Properties\Settings.Designer.cs
     文件         249  2019-01-31 10:31  MemCachedWatch\MemCachedWatch\Properties\Settings.settings
     文件         985  2019-02-01 07:40  MemCachedWatch\MemCachedWatch\app.config
     目录           0  2019-01-31 17:03  MemCachedWatch\MemCachedWatch\bin\
     目录           0  2019-01-31 16:58  MemCachedWatch\MemCachedWatch\bin\Debug\
     文件      153600  2018-12-20 13:09  MemCachedWatch\MemCachedWatch\bin\Debug\Enyim.Caching.dll
     文件       47616  2019-02-01 07:47  MemCachedWatch\MemCachedWatch\bin\Debug\MemCachedWatch.exe
     文件         985  2019-02-01 07:40  MemCachedWatch\MemCachedWatch\bin\Debug\MemCachedWatch.exe.config
     文件       34304  2019-02-01 07:47  MemCachedWatch\MemCachedWatch\bin\Debug\MemCachedWatch.pdb
     文件       65536  2007-06-07 10:28  MemCachedWatch\MemCachedWatch\bin\Debug\Memcached.ClientLibrary.dll
     文件      234515  2018-03-01 17:24  MemCachedWatch\MemCachedWatch\bin\Debug\cygevent-2-0-5.dll
     文件      139283  2018-03-01 17:24  MemCachedWatch\MemCachedWatch\bin\Debug\cygevent_core-2-0-5.dll
     文件      108563  2018-03-01 17:24  MemCachedWatch\MemCachedWatch\bin\Debug\cygevent_extra-2-0-5.dll
     文件       21523  2018-03-01 17:24  MemCachedWatch\MemCachedWatch\bin\Debug\cygevent_openssl-2-0-5.dll
     文件       10259  2018-03-01 17:24  MemCachedWatch\MemCachedWatch\bin\Debug\cygevent_pthreads-2-0-5.dll
     文件     3195569  2018-03-01 17:24  MemCachedWatch\MemCachedWatch\bin\Debug\cygwin1.dll
     文件      294912  2017-02-14 22:11  MemCachedWatch\MemCachedWatch\bin\Debug\log4net.dll
     文件      181760  2018-03-01 17:24  MemCachedWatch\MemCachedWatch\bin\Debug\memcached.exe
............此处省略23个文件信息

评论

共有 条评论