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.
25 lines
500 B
C#
25 lines
500 B
C#
using System;
|
|
using NewLife.Caching;
|
|
|
|
namespace Tool
|
|
{
|
|
public class CacheManager
|
|
{
|
|
|
|
public static void Act(string key,Action action)
|
|
{
|
|
ICache _cache=Cache.Default;
|
|
if(_cache.ContainsKey(key)) return;
|
|
try
|
|
{
|
|
_cache.Set(key, TimeSpan.FromSeconds(3000));
|
|
action();
|
|
}
|
|
finally
|
|
{
|
|
_cache.Remove(key);
|
|
}
|
|
|
|
}
|
|
}
|
|
} |