非常难题 现数据库内有信息百万条,我希望客户端每次登陆后,信息都存在缓存中,是否可行(winform) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 写一个缓存类存取namespace HZ{ using System.Collections.Generic; /**//// <summary> /// 全局统一的缓存类 /// </summary> public class Cache { private SortedDictionary<string, string> dic = new SortedDictionary<string, string>(); private static volatile Cache instance = null; private static object lockHelper = new object(); private Cache() { } public void Add(string key, string value) { dic.Add(key, value); } public void Remove(string key) { dic.Remove(key); } public string this[string index] { get { if (dic.ContainsKey(index)) return dic[index]; else return null; } set { dic[index] = value; } } public static Cache Instance { get { if (instance == null) { lock (lockHelper) { if (instance == null) { instance = new Cache(); } } } return instance; } } }} 发送邮件问题 C#智能项目生成exe文件读取sqlCE 问题 象有道翻译软件那样的在鼠标处显示一个列表框怎么做? Data Table 数据上传 C#中属性的get和set类型要一样吗 题目求解答 高手请进 请教关于NET框架的概念性问题 用POP3取邮件时,使用正确的密码,但检测结果返回-ERR 如何改变exe文件的图标? 300分 请教c# & java达人 用C#代码怎么取另一个机子的IP号和端口号?急!!!
{
using System.Collections.Generic; /**//// <summary>
/// 全局统一的缓存类
/// </summary>
public class Cache
{
private SortedDictionary<string, string> dic = new SortedDictionary<string, string>();
private static volatile Cache instance = null;
private static object lockHelper = new object(); private Cache()
{ }
public void Add(string key, string value)
{
dic.Add(key, value);
}
public void Remove(string key)
{
dic.Remove(key);
} public string this[string index]
{
get
{
if (dic.ContainsKey(index))
return dic[index];
else
return null;
}
set { dic[index] = value; }
} public static Cache Instance
{
get
{
if (instance == null)
{
lock (lockHelper)
{
if (instance == null)
{
instance = new Cache();
}
}
}
return instance;
}
}
}
}