/// <summary> /// Try to get a state by its key /// </summary> /// <param name="key"></param> /// <param name="state"></param> /// <returns></returns> public bool TryGet(string key, out HandshakeState state) { if (Cache.Contains(key)) { object tmp = Cache[key]; if (tmp != null) { state = (HandshakeState)tmp; return(true); } } state = default(HandshakeState); return(false); }
/// <summary> /// Try to get a state by its key /// </summary> /// <param name="key"></param> /// <param name="state"></param> /// <returns></returns> public bool TryGet(string key, out HandshakeState state) { if (Cache.Contains(key)) { object tmp = Cache[key]; if (tmp != null) { state = (HandshakeState)tmp; return true; } } state = default(HandshakeState); return false; }
/// <summary> /// Add a new state to the cache and set a custom cache item policy /// </summary> /// <param name="key"></param> /// <param name="state"></param> /// <param name="policy"></param> public void Add(string key, HandshakeState state, CacheItemPolicy policy) { this.Cache.Set(key, state, policy); }
/// <summary> /// Add a new state to the cache /// </summary> /// <param name="key"></param> /// <param name="state"></param> public void Add(string key, HandshakeState state) { this.Cache.Set(key, state, GetCacheItemPolicy(this.ExpirationTime)); }