Zeus2's Blog
博客园
首页
新随笔
新文章
联系
管理
订阅
随笔- 26 文章- 3 评论- 20
2008年8月9日
WinForm使用的缓存类
给Winform使用的缓存类
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;
}
}
}
}
写得不好请多指教。主要是由于现在计算机内存太大了,就应该让程序合理使用内存提高速度。
posted @
2008-08-09 18:40
zeus2 阅读(247) |
评论 (3)
|
编辑
<
2008年8月
>
日
一
二
三
四
五
六
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
与我联系
发短消息
搜索
常用链接
我的随笔
我的空间
我的短信
我的评论
更多链接
我的参与
我的新闻
最新评论
我的标签
留言簿
给我留言
查看留言
我参加的小组
NHibernate
Visual Studio
我的标签
C# 多线程 空间 访问
(1)
C# 排序 算法
(1)
C++ Sqlite
(1)
随笔分类
ASP.NET
C#(1)
随笔档案
2008年11月 (2)
2008年8月 (1)
2008年5月 (1)
2008年3月 (1)
2008年1月 (1)
2007年12月 (3)
2007年11月 (3)
2007年7月 (5)
2007年6月 (9)
最新评论
阅读排行榜
1. 无软盘安装SATA硬盘的XP系统并启用AHCI模式(2064)
2. Microsoft Visual Studio 2008 Team Suite ZWT发飙了(1061)
3. Visual Studio 2008 响应很慢 是怎么回事?(575)
4. asp.net 2.0使用sqlite!(570)
5. sqlite怎么读不出中文来(392)
评论排行榜
1. Visual Studio 2008发布了(5)
2. Microsoft Visual Studio 2008 Team Suite ZWT发飙了(4)
3. 机子出问题了,向各位求助!(4)
4. WinForm使用的缓存类(3)
5. sqlite怎么读不出中文来(2)