namespace JNPF.Extras.CollectiveOAuth.Cache; /// /// 授权状态默认缓存. /// public class DefaultAuthStateCache : IAuthStateCache { /// /// 默认缓存前缀. /// private static string Default_Cache_Prefix = "CollectiveOAuth_Status_"; /// /// 保存缓存. /// /// 键. /// 值. public void cache(string key, string value) { HttpRuntimeCache.Set($"{Default_Cache_Prefix}{key}", value); } /// /// 保存缓存. /// /// 键. /// 值. /// 过期时间戳. public void cache(string key, string value, long timeout) { HttpRuntimeCache.Set($"{Default_Cache_Prefix}{key}", value, timeout); } /// /// 是否存在. /// /// 键. /// true or false. public bool containsKey(string key) { var cacheObj = HttpRuntimeCache.Get($"{Default_Cache_Prefix}{key}"); if (cacheObj != null) { return true; } return false; } /// /// 取值缓存. /// /// 键. /// public string get(string key) { var cacheObj = HttpRuntimeCache.Get($"{Default_Cache_Prefix}{key}"); if (cacheObj != null) { return Convert.ToString(cacheObj); } else { return null; } } }