You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CaiQie/Tool/CacheManager.cs

25 lines
500 B
C#

2 days ago
using System;
using NewLife.Caching;
namespace Tool
2 days ago
{
public class CacheManager
{
2 days ago
public static void Act(string key,Action action)
{
ICache _cache=Cache.Default;
if(_cache.ContainsKey(key)) return;
try
{
_cache.Set(key, TimeSpan.FromSeconds(3000));
2 days ago
action();
}
finally
{
_cache.Remove(key);
}
}
2 days ago
}
}