/// <summary> /// Registers an internal <b>Policy Key</b> (using the <see cref="InternalPolicyKeyFormat"/>) with a <see cref="NoCachePolicy"/> to ensure always invoked; /// it is then expected that the <see cref="OnFlushCache(bool)"/> will handle policy expiration specifically. /// </summary> protected void RegisterInternalPolicyKey() { var overridePolicyKey = string.Format(System.Globalization.CultureInfo.InvariantCulture, InternalPolicyKeyFormat, PolicyKey); CachePolicyManager.Register(this, overridePolicyKey); CachePolicyManager.Set(overridePolicyKey, new NoCachePolicy()); }
/// <summary> /// Registers an internal <b>Policy Key</b> (using the <see cref="InternalPolicyKeyFormat"/>) with a <see cref="NoCachePolicy"/> to ensure always invoked; /// it is then expected that the <see cref="OnFlushCache(bool)"/> will handle policy expiration specifically. /// </summary> protected void RegisterInternalPolicyKey() { var overridePolicyKey = string.Format(InternalPolicyKeyFormat, PolicyKey); CachePolicyManager.Register(this, overridePolicyKey); CachePolicyManager.Set(overridePolicyKey, new NoCachePolicy()); }
/// <summary> /// Initializes a new instance of the <see cref="CacheCoreBase"/> class that automatically <see cref="CachePolicyManager.Register">registers</see> for centralised <see cref="CachePolicyManager.Flush"/> management. /// </summary> /// <param name="policyKey">The policy key used to determine the cache policy configuration (see <see cref="CachePolicyManager"/>); defaults to <see cref="Guid.NewGuid()"/> ensuring uniqueness.</param> /// <param name="doNotRegister">Indicates that the automatic <see cref="CachePolicyManager.Register"/> should not occur (inheriting class must perform).</param> protected CacheCoreBase(string?policyKey = null, bool doNotRegister = false) { PolicyKey = string.IsNullOrEmpty(policyKey) ? Guid.NewGuid().ToString() : policyKey; if (!doNotRegister) { CachePolicyManager.Register(this); } }