(#3)如果没有找到数据返回null

This commit is contained in:
falcon 2019-03-04 13:57:58 +08:00
parent 7ad681c79a
commit be607f4f21

View File

@ -16,7 +16,7 @@ namespace Cmdjy.Bll
/// <typeparam name="T">数据类型</typeparam>
/// <param name="key">保存的key</param>
/// <returns>缓存的数据</returns>
T GetData<T>(string key);
T GetData<T>(string key) where T : class;
/// <summary>
/// 缓存数据,缓存时间默认
/// </summary>
@ -55,8 +55,8 @@ namespace Cmdjy.Bll
this.Database = this.Database ?? Connection.GetDatabase(0);
}
public T GetData<T>(string key) {
if(!Usable) return default(T);
public T GetData<T>(string key) where T : class {
if(!Usable) return null;
return fromJson<T>(Database.StringGet(key));
}