发文章
发文工具
撰写
网文摘手
文档
视频
思维导图
随笔
相册
原创同步助手
其他工具
图片转文字
文件清理
AI助手
留言交流
.NET版本服务端 http://pan.baidu.com/share/link?shareid=3505343637&uk=3928651495
.NET版本客户端 http://pan.baidu.com/share/link?shareid=3511558869&uk=3928651495
封装类
/// <summary> /// MemCache帮助类 /// 根据配置文件里的Serverlist节点读取分布式缓存服务器列表 格式为 "127.0.0.1:11211" ,"127.0.0.2:11211" /// 如果Web.config未配置。则服务器默认为 127.0.0.1:11211 /// </summary> public class CachedHelper { /// <summary> /// 设置缓存_如果KEY存在_则更新 /// </summary> /// <param name="Key">Key</param> /// <param name="Value">Value</param> /// <param name="times">过期时间点_为当前时间加上此值(单位为妙)</param> public static void SetMemCache(string Key, object Value, double times) { SockIOPool pool; MemcachedClient mc; init(out pool, out mc); mc.Set(Key, Value, DateTime.Now.AddSeconds(times)); pool.Shutdown();//关闭连接池 } /// <summary> /// 设置缓存_如果KEY存在_则更新 /// </summary> /// <param name="Key">Key</param> /// <param name="Value">Value</param> public static void SetMemCache(string Key, object Value) { SockIOPool pool; MemcachedClient mc; init(out pool, out mc); mc.Set(Key, Value); pool.Shutdown();//关闭连接池 } /// <summary> /// 根据Key读取缓存_如果读不到_返回空字符串 /// </summary> /// <param name="Key"></param> /// <returns></returns> public static object GetMemcache(string Key) { SockIOPool pool; MemcachedClient mc; init(out pool, out mc); object value = mc.Get(Key) ?? ""; pool.Shutdown();//关闭连接池 return value; } /// <summary> /// 服务器初始化 /// </summary> /// <param name="pool"></param> /// <param name="mc"></param> private static void init(out SockIOPool pool, out MemcachedClient mc) { string ConServerlist = System.Configuration.ConfigurationManager.AppSettings.Get("Serverlist"); if (string.IsNullOrEmpty(ConServerlist)) { ConServerlist = "127.0.0.1:11211"; } ///初始化memcached 服务器端集群列表。 string[] serverlist = ConServerlist.Split(','); pool = SockIOPool.GetInstance("MemCache"); //设置怎么mem池连接点服务器端。 pool.SetServers(serverlist); pool.Initialize(); //创建了一个mem客户端的代理类。 mc = new MemcachedClient(); mc.PoolName = "MemCache"; mc.EnableCompression = false; } }
来自: 昵称10504424 > 《工作》
0条评论
发表
请遵守用户 评论公约
Memcached 高性能的分布式内存对象缓存系统 Memcached的安装、使用实例
Memcached 高性能的分布式内存对象缓存系统 Memcached的安装、使用实例。在上图中点击“memcached-1.2.6-win32-bin.zip”进入下载页面,...
Java的Memcached客户端
ASP.NET使用Memcached高缓存实例(初级教程) - VC/MFC/C++/ja...
ASP.NET使用Memcached高缓存实例(初级教程) - VC/MFC/C++/ja...Memcached是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载。四,配置 memcached使用了log4net,所以我们先...
分布式缓存系统Memcached简介与实践
Memcached是什么?Memcached是由Danga Interactive开发的,高性能的,分布式的内存对象缓存系统,用于在动态应用中减少数据库负载,提升访问速度。Memcached的特点Memcached的缓存是一种分布式的,可以...
缓存-MemCache
缓存-MemCacheMemcache是一个高性能的分布式的内存对象缓存系统,通过在内存里维护一个统一的巨大的hash表,它能够用来存储各种格式的数据,包括图像、视频、文件以及数据库检索的结果等。''c:...
memcached搭建缓存系统
memcached搭建缓存系统。Memcached可以缓存String,也可以缓存自定义java bean。Java代码 package com.hl.memcached.cache.client; import java.io.Serializable; public class TestBean implem...
memcache讲解和在.net中初使用
memcache讲解和在.net中初使用memcache讲解和在.net中初使用2017年10月17日 22:51:36?等待临界?阅读数:503?memcache官网?memcached是一...
Memcached安装、使用、与AOP集成
protected static SockIOPool pool = null;//从Memcached中获取 obj = mcc.get(this.class.getName() + mi.getMethodName() + args.hashcode()); if(obj != null) { return o...
横向扩展(Facebook)
在弗吉尼亚的MySQL数据库作为西海 岸的数据库的从数据库(Slave)运行,所以我们花了几周的时间复制所有的数据,然后建立同步复制流(replication stream)。| MEMCACHE_DIRTY mc_key_list;我将"M...
微信扫码,在手机上查看选中内容