using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Caching;
namespace EncourageUser
{
public class Common
{
///
/// 缓存是否存在
///
///
///
///
///
public static bool GetCache(string text)
{
try
{
Cache cache = HttpRuntime.Cache;
object item = cache[text];
return item != null ? true : false;
}
catch (Exception)
{ }
return false;
}
///
/// 设置缓存(辅助输入)
///
///
///
///
///
public static bool SetCache(string text)
{
try
{
Cache cache = HttpRuntime.Cache;
//查找 md5 的缓存,不存在则返回null
object item = cache[text];
if (item == null)
cache.Insert(text, 1, null, DateTime.Now.AddMinutes(1), Cache.NoSlidingExpiration);
return true;
}
catch (Exception ex)
{ }
return false;
}
}
}