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#

5 days ago
using System;
using NewLife.Caching;
namespace Tool
5 days ago
{
public class CacheManager
{
5 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));
5 days ago
action();
}
finally
{
_cache.Remove(key);
}
}
5 days ago
}
}