using System;
using CacheManager.Core;
namespace PhoenixLib.Caching
{
///
/// Extensions for the configuration builder specific to System.Runtime.Caching cache handle.
///
public static class RuntimeCachingBuilderExtensions
{
private const string DEFAULT_NAME = "default";
///
/// Adds a using a .
/// The name of the cache instance will be 'default'.
///
/// The builder part.
///
/// Set this to true if this cache handle should be the source of the backplane.
/// This setting will be ignored if no backplane is configured.
///
///
/// The builder part.
///
/// The builder part.
public static ConfigurationBuilderCacheHandlePart WithSystemRuntimeCacheHandle(this ConfigurationBuilderCachePart part, bool isBackplaneSource = false)
=> part?.WithHandle(typeof(MemoryCacheHandle<>), DEFAULT_NAME, isBackplaneSource);
///
/// Adds a using a
/// instance with the given .
/// The named cache instance can be configured via app/web.config system.runtime.caching section.
///
/// The builder part.
/// The name to be used for the cache instance.
///
/// Set this to true if this cache handle should be the source of the backplane.
/// This setting will be ignored if no backplane is configured.
///
///
/// The builder part.
///
/// If part is null.
/// Thrown if is null.
public static ConfigurationBuilderCacheHandlePart WithSystemRuntimeCacheHandle(this ConfigurationBuilderCachePart part, string instanceName, bool isBackplaneSource = false)
=> part?.WithHandle(typeof(MemoryCacheHandle<>), instanceName, isBackplaneSource);
}
}