开发者社区> 问答> 正文

OCS服务,CSharp客户端清空缓存FlushAll,缓存数据没有清空?有人遇到吗?

C#客户端FlushAll(),缓存数据没有清空,怎么回事?有人遇到吗?
若是Remove(cache_key)是可以。
代码如下:
写入:

MemcachedClient cacheClient =GetInstance();
bool isSuccess = cacheClient.Store(StoreMode.Set, cache_key, "hello");
清空:

MemcachedClient cacheClient = GetInstance();
cacheClient.FlushAll();


--------------------

        private static MemcachedClient MemClient;
        static readonly object padlock = new object();
        //线程安全的单例模式
        public static MemcachedClient GetInstance()
        {
            if (MemClient == null)
            {
                lock (padlock)
                {
                    if (MemClient == null)
                    {
                        MemClientInit();                        
                    }
                }
            }
            return MemClient;
        }


        static void MemClientInit()
        {
            //初始化缓存
            MemcachedClientConfiguration memConfig = new MemcachedClientConfiguration();
            IPAddress newaddress = IPAddress.Parse(Dns.GetHostEntry("实例ID.m.cnhzaliqshpub001.ocs.aliyuncs.com").AddressList[0].ToString()); //your_instanceid替换为你的OCS实例的ID
            IPEndPoint ipEndPoint = new IPEndPoint(newaddress, 11211);
              // 配置文件 - ip
            memConfig.Servers.Add(ipEndPoint);
            // 配置文件 - 协议
           memConfig.Protocol = MemcachedProtocol.Binary;
            // 配置文件-权限,如果使用了免密码功能,则无需设置userName和password
            memConfig.Authentication.Type = typeof(PlainTextAuthenticator);
            memConfig.Authentication.Parameters["zone"] = "";
            memConfig.Authentication.Parameters["userName"] = "实例 uesrname";
            memConfig.Authentication.Parameters["password"] = "实例password";
      //下面请根据实例的最大连接数进行设置
            memConfig.SocketPool.MinPoolSize = 5;
            memConfig.SocketPool.MaxPoolSize = 200;
            MemClient=new MemcachedClient(memConfig);
                  }
          }

展开
收起
东方虹 2015-03-03 21:07:48 7760 0
1 条回答
写回答
取消 提交回答
  • 阿里云对象存储(OSS)开发工程师
    ReOCS服务,CSharp客户端清空缓存FlushAll,缓存数据没有清空?有人遇到吗
    这里是OSS的板块,能回答你问题的估计不多,你可以到阿里云的官网提工单解决你的问题
    2015-03-04 19:10:24
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
基于英特尔 SSD 的虚拟机缓存解决SSD 立即下载
用户态高速块缓存方案 立即下载
高性能Web架构之缓存体系 立即下载