- public void AddItemToCache(Object sender, EventArgs e) {! Z, e' g# z% \" s
- itemRemoved = false;
, d6 `& `5 h" \/ ^ M, T6 T2 c& W/ ~3 X/ m
) L0 K0 d+ L* X! q5 y- onRemove = new CacheItemRemovedCallback(this.RemovedCallback);/ V5 _& }6 Y8 `& A# K+ c2 | s1 o
- 4 I" O0 i9 M4 \- t0 I V! `9 @& p0 b
- if (Cache["Key1"] == null), w; W: r- \% y6 ^8 v6 H" U ^/ S, s
- Cache.Add("Key1", "Value 1", null, DateTime.Now.AddSeconds(60), TimeSpan.Zero, CacheItemPriority.High, onRemove);* T2 w5 H1 S- Y" n( I% u
- }
复制代码 详见:http://msdn.microsoft.com/zh-cn/ ... b.caching.cache.add(VS.80).aspx |