### CacheManager Get Operation Example Source: https://cachemanager.michaco.net/documentation/cachemanager_logging Demonstrates the code for retrieving an item from the cache. ```csharp var val = cache.Get("key"); ``` -------------------------------- ### Build a String Cache Source: https://cachemanager.michaco.net/ Initializes a new cache instance for string types using the System.Runtime.Cache handle. This is a basic setup for getting started. ```csharp var manager = CacheFactory.Build( p => p.WithSystemRuntimeCacheHandle()); ``` -------------------------------- ### Complete CacheManager JSON Configuration Example Source: https://cachemanager.michaco.net/documentation/CacheManagerConfiguration A comprehensive example of a CacheManager JSON configuration, including Redis backplane, cache managers, handles, and serializers. Ensure you have the necessary NuGet packages installed for the specified types. ```json { "$schema": "http://cachemanager.michaco.net/schemas/cachemanager.json#", "redis": [ { "key": "redisConnection", "connectionString": "localhost:6379,allowAdmin=true" } ], "cacheManagers": [ { "maxRetries": 1000, "name": "cachename", "retryTimeout": 100, "updateMode": "Full", "backplane": { "key": "redisConnection", "knownType": "Redis", "channelName": "test" }, "loggerFactory": { "knownType": "Microsoft" }, "serializer": { "knownType": "Json" }, "handles": [ { "knownType": "SystemRuntime", "enablePerformanceCounters": true, "enableStatistics": true, "expirationMode": "Absolute", "expirationTimeout": "0:0:23", "isBackplaneSource": false, "name": "sys cache" }, { "knownType": "Redis", "key": "redisConnection", "isBackplaneSource": true } ] } ] } ``` -------------------------------- ### Install CacheManager Core Source: https://cachemanager.michaco.net/ Installs the core functionality of CacheManager. ```powershell Install-Package CacheManager.Core ``` -------------------------------- ### Full CacheManager Console Application Example Source: https://cachemanager.michaco.net/documentation/CacheManagerGettingStarted A complete C# console application example demonstrating the initialization and usage of CacheManager, including adding, updating, retrieving, and removing cache items. This code includes the necessary using statements and the Main method structure. ```csharp static void Main(string[] args) { var cache = CacheFactory.Build("getStartedCache", settings => { settings.WithSystemRuntimeCacheHandle("handleName"); }); cache.Add("keyA", "valueA"); cache.Put("keyB", 23); cache.Update("keyB", v => 42); Console.WriteLine("KeyA is " + cache.Get("keyA")); // should be valueA Console.WriteLine("KeyB is " + cache.Get("keyB")); // should be 42 cache.Remove("keyA"); Console.WriteLine("KeyA removed? " + (cache.Get("keyA") == null).ToString()); Console.WriteLine("We are done..."); Console.ReadKey(); } ``` -------------------------------- ### Install CacheManager StackExchange.Redis Provider Source: https://cachemanager.michaco.net/ Installs the StackExchange.Redis caching provider for CacheManager. ```powershell Install-Package CacheManager.StackExchange.Redis ``` -------------------------------- ### Install CacheManager Web Provider Source: https://cachemanager.michaco.net/ Installs the Web caching provider for CacheManager. ```powershell Install-Package CacheManager.Web ``` -------------------------------- ### Install CacheManager JSON Serialization Source: https://cachemanager.michaco.net/ Installs the JSON serialization provider for CacheManager. ```powershell Install-Package CacheManager.Serialization.Json ``` -------------------------------- ### Install CacheManager SystemRuntimeCaching Provider Source: https://cachemanager.michaco.net/ Installs the System.Runtime.Caching provider for CacheManager. ```powershell Install-Package CacheManager.SystemRuntimeCaching ``` -------------------------------- ### CacheManager Add Operation Example Source: https://cachemanager.michaco.net/documentation/cachemanager_logging Demonstrates the code for adding an item to the cache. ```csharp cache.Add("key", "value"); ``` -------------------------------- ### Cache Initialization Source: https://cachemanager.michaco.net/documentation/CacheManagerUpdateOperations Create a cache instance using CacheFactory.Build. This example configures a string cache with a SystemRuntimeCacheHandle. ```csharp var cache = CacheFactory.Build( "myCache", s => s.WithSystemRuntimeCacheHandle("handle")); Console.WriteLine("Testing update..."); ``` -------------------------------- ### Initialize RedisConfiguration with Detailed Parameters Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Redis.RedisConfiguration.html Use this constructor to initialize RedisConfiguration with a comprehensive set of parameters, including connection details, security settings, and operational flags. This is useful when you need fine-grained control over the Redis connection. ```csharp public RedisConfiguration(string key, IList endpoints, int database = 0, string password = null, bool isSsl = false, string sslHost = null, int connectionTimeout = 5000, bool allowAdmin = false, bool keyspaceNotificationsEnabled = false, bool twemproxyEnabled = false, string strictCompatibilityModeVersion = null) ``` -------------------------------- ### Initialize RedisConfiguration with Connection String Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Redis.RedisConfiguration.html Use this constructor to initialize RedisConfiguration using a single connection string. This simplifies configuration when all necessary details are available in a standard connection string format. ```csharp public RedisConfiguration(string key, string connectionString, int database = 0, bool keyspaceNotificationsEnabled = false, string strictCompatibilityModeVersion = null) ``` -------------------------------- ### Build IConfiguration with JSON file Source: https://cachemanager.michaco.net/documentation/CacheManagerConfiguration Demonstrates how to build an IConfiguration object by adding a JSON configuration file. This is the first step before loading CacheManager configurations. ```csharp var builder = new Microsoft.Extensions.Configuration.ConfigurationBuilder() .AddJsonFile("cache.json"); this.Configuration = builder.Build(); ``` -------------------------------- ### StrictCompatibilityModeVersion Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Redis.RedisConfiguration.html Gets or sets a version number to eventually reduce the available features accessible by CacheManager. For example, set this to "2.4" to disable LUA support. ```APIDOC ## StrictCompatibilityModeVersion ### Description Gets or sets a version number to eventually reduce the avaible features accessible by cachemanager. E.g. set this to `"2.4"` to disable LUA support. ### Property `StrictCompatibilityModeVersion` ### Type `String` ### Remarks This can also be used when automatic feature detection is not possible. Which is the case for example if TwemProxy is used, because the servers collection. to query the features, is not available/supported. CacheManager per default falls back to a version which supports LUA. If you are using a Redis server behind TwemPoxy which does not allow LUA, use this property! ``` -------------------------------- ### Initialize RedisConfiguration with Default Values Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Redis.RedisConfiguration.html Use this constructor to create a new instance of RedisConfiguration with default settings. No specific configuration is provided. ```csharp public RedisConfiguration() ``` -------------------------------- ### Get Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.ICache-1.html Gets a value for the specified key. ```APIDOC ## Get(String) ### Description Gets a value for the specified key. ### Method Not specified (likely returns a value). ### Endpoint Not applicable (SDK method). ### Parameters #### Path Parameters None. #### Query Parameters None. #### Request Body None. ### Parameters - **key** (String) - Required - The key being used to identify the item within the cache. ### Returns - **TCacheValue**: The value being stored in the cache for the given key. ### Exceptions - **ArgumentNullException**: If the key is null. ``` -------------------------------- ### Standard Cache Operations Source: https://cachemanager.michaco.net/documentation/CacheManagerArchitecture Demonstrates basic cache operations like adding, getting, removing, and clearing items. Use 'Add' to create new keys and 'Put' to override existing ones. ```csharp cache.Add("key", "value"); var value = cache.Get("key"); cache.Remove("key"); cache.Clear(); ``` -------------------------------- ### Get(String) Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Core.ICache-1.html Gets a value for the specified key. ```APIDOC ## Get(String) ### Description Gets a value for the specified key. ### Method TCacheValue Get(string key) ### Endpoint N/A (SDK Method) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Parameters #### Path Parameters - **key** (string) - Required - The key being used to identify the item within the cache. ### Returns #### Success Response - **TCacheValue**: The value being stored in the cache for the given key. ### Exceptions - **ArgumentNullException**: If the key is null. ``` -------------------------------- ### Get Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.ICache-1.html Gets a value for the specified key and region. ```APIDOC ## Get(String, String) ### Description Gets a value for the specified key and region. ### Method Not specified (likely returns a value). ### Endpoint Not applicable (SDK method). ### Parameters #### Path Parameters None. #### Query Parameters None. #### Request Body None. ### Parameters - **key** (String) - Required - The key being used to identify the item within the cache. - **region** (String) - Required - The cache region. ### Returns - **TCacheValue**: The value being stored in the cache for the given key and region. ### Exceptions - **ArgumentNullException**: If the key or region is null. ``` -------------------------------- ### Initialize ServerEndPoint with Host and Port Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Redis.ServerEndPoint.html Use this constructor to initialize a ServerEndPoint with a specific host and port. Ensure the host string is not null. ```csharp public ServerEndPoint(string host, int port) ``` -------------------------------- ### Get(String, String) Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Core.ICache-1.html Gets a value for the specified key and region. ```APIDOC ## Get(String, String) ### Description Gets a value for the specified key and region. ### Method TCacheValue Get(string key, string region) ### Endpoint N/A (SDK Method) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Parameters #### Path Parameters - **key** (string) - Required - The key being used to identify the item within the cache. - **region** (string) - Required - The cache region. ### Returns #### Success Response - **TCacheValue**: The value being stored in the cache for the given key and region. ### Exceptions - **ArgumentNullException**: If the key or region is null. ``` -------------------------------- ### Configure Multiple Cache Handles Source: https://cachemanager.michaco.net/documentation/CacheManagerArchitecture Demonstrates configuring a CacheManager instance with multiple cache handles, including System.Runtime.Caching and Redis, in sequence. ```csharp var cache = CacheFactory.Build("myCacheName", settings => { settings .WithSystemRuntimeCacheHandle("handle1") .And .WithRedisCacheHandle("redis"); }); ``` -------------------------------- ### Get(String) Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.Internal.BaseCache-1.html Gets a value from the cache using the specified key. ```APIDOC ## Get(String) ### Description Gets a value from the cache using the specified key. ### Method GET ### Endpoint /api/cache/{key} ### Parameters #### Path Parameters - **key** (String) - Required - The key being used to identify the item within the cache. ### Response #### Success Response (200) - **Value** (TCacheValue) - The value being stored in the cache for the given key. #### Error Response (400) - **Error** (ArgumentNullException) - If the key is null. ``` -------------------------------- ### Basic Cache Operations Source: https://cachemanager.michaco.net/ Demonstrates adding, updating, retrieving, and putting values into the cache. Use 'AddOrUpdate' for conditional updates and 'Get'/'Put' for direct access. ```csharp manager.AddOrUpdate("key", "value", _ => "updated value"); var val = manager.Get("key"); manager.Put("key", "another value"); ``` -------------------------------- ### SystemWebCacheHandle Constructor Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Web.SystemWebCacheHandle-1.html Initializes a new instance of the SystemWebCacheHandle class. Requires manager configuration, cache handle configuration, and a logger factory. ```csharp public SystemWebCacheHandle(ICacheManagerConfiguration managerConfiguration, CacheHandleConfiguration configuration, ILoggerFactory loggerFactory) ``` -------------------------------- ### Get Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.ICache-1.html Gets a value for the specified key and will cast it to the specified type. ```APIDOC ## Get(String) ### Description Gets a value for the specified key and will cast it to the specified type. ### Method Not specified (likely returns a value). ### Endpoint Not applicable (SDK method). ### Parameters #### Path Parameters None. #### Query Parameters None. #### Request Body None. ### Parameters - **key** (String) - Required - The key being used to identify the item within the cache. ### Returns - **TOut**: The value being stored in the cache for the given key. ### Type Parameters - **TOut**: The type the value is converted and returned. ### Exceptions - **ArgumentNullException**: If the key is null. - **InvalidCastException**: If no explicit cast is defined from `TCacheValue` to `TOut`. ``` -------------------------------- ### Initialize CacheManager with System.Runtime.Caching Source: https://cachemanager.michaco.net/documentation/CacheManagerGettingStarted This snippet shows how to build a CacheManager instance using the System.Runtime.Caching handle. Ensure the CacheManager.SystemRuntimeCaching NuGet package is installed. ```csharp using System; using CacheManager.Core; namespace ConsoleApplication { class Program { static void Main(string[] args) { var cache = CacheFactory.Build("getStartedCache", settings => { settings.WithSystemRuntimeCacheHandle("handleName"); }); } } } ``` -------------------------------- ### Build Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.ConfigurationBuilderCachePart.html Hands back the new CacheManagerConfiguration instance. ```APIDOC ## Build() ### Description Hands back the new CacheManagerConfiguration instance. ### Method `public ICacheManagerConfiguration Build()` ### Returns - **ICacheManagerConfiguration**: The ICacheManagerConfiguration. ``` -------------------------------- ### Build Cache Manager from App.config with Instance and Cache Names Source: https://cachemanager.michaco.net/documentation/cachemanager_configuration Use CacheFactory.FromConfiguration with separate instance and cache names to create multiple instances from the same configuration. ```csharp var cache = CacheFactory.FromConfiguration("cacheInstanceName", "configuredCacheName") ``` -------------------------------- ### Initialize RedisConfigurationBuilder Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Redis.RedisConfigurationBuilder.html Initializes a new instance of the RedisConfigurationBuilder class using a configuration key. ```csharp public RedisConfigurationBuilder(string configurationKey) ``` -------------------------------- ### Install CacheManager Memcached Provider Source: https://cachemanager.michaco.net/ Installs the Memcached caching provider for CacheManager. ```powershell Install-Package CacheManager.Memcached ``` -------------------------------- ### Install CacheManager Couchbase Provider Source: https://cachemanager.michaco.net/ Installs the Couchbase caching provider for CacheManager. ```powershell Install-Package CacheManager.Couchbase ``` -------------------------------- ### TryUpdate Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.ICacheManager-1.html Tries to update an existing key in the cache. The cache manager will make sure the update will always happen on the most recent version. If version conflicts occur, if for example multiple cache clients try to write the same key, and during the update process, someone else changed the value for the key, the cache manager will retry the operation. The updateValue function will get invoked on each retry with the most recent value which is stored in cache. ```APIDOC ## TryUpdate(String key, Func updateValue, out TCacheValue value) ### Description Tries to update an existing key in the cache. The cache manager will make sure the update will always happen on the most recent version. If version conflicts occur, if for example multiple cache clients try to write the same key, and during the update process, someone else changed the value for the key, the cache manager will retry the operation. The updateValue function will get invoked on each retry with the most recent value which is stored in cache. ### Method bool ### Parameters #### Path Parameters - **key** (String) - Required - The key to update. - **updateValue** (Func) - Required - The function to perform the update. - **value** (out TCacheValue) - Required - The updated value, or null, if the update was not successful. ### Returns - **Boolean** - `True` if the update operation was successful, `False` otherwise. ### Remarks If the cache does not use a distributed cache system. Update is doing exactly the same as Get plus Put. ### Exceptions - **ArgumentNullException** - If key or updateValue are null. ``` -------------------------------- ### Build Configuration Separately and Create Cache Manager Source: https://cachemanager.michaco.net/documentation/CacheManagerConfiguration Use ConfigurationBuilder to create a configuration object first, then use it with CacheFactory.FromConfiguration to instantiate a cache manager. ```csharp var cfg = ConfigurationBuilder.BuildConfiguration(settings => { settings.WithUpdateMode(CacheUpdateMode.Up) .WithSystemRuntimeCacheHandle("handleName") .WithExpiration(ExpirationMode.Sliding, TimeSpan.FromSeconds(10)); }); var cache = CacheFactory.FromConfiguration("cacheName", cfg); cache.Add("key", "value"); ``` -------------------------------- ### Get(String) Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Core.ICache-1.html Gets a value for the specified key and will cast it to the specified type. ```APIDOC ## Get(String) ### Description Gets a value for the specified key and will cast it to the specified type. ### Method TOut Get(string key) ### Endpoint N/A (SDK Method) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Parameters #### Path Parameters - **key** (string) - Required - The key being used to identify the item within the cache. ### Type Parameters - **TOut** (Type) - The type the value is converted and returned. ### Returns #### Success Response - **TOut**: The value being stored in the cache for the given key. ### Exceptions - **ArgumentNullException**: If the key is null. - **InvalidCastException**: If no explicit cast is defined from `TCacheValue` to `TOut`. ``` -------------------------------- ### Build() Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Redis.RedisConfigurationBuilder.html Creates the RedisConfiguration out of the currently specified properties, if possible. ```APIDOC ## Build() ### Description Creates the RedisConfiguration out of the currently specified properties, if possible. ### Method Method ### Returns #### Success Response - **RedisConfiguration** (RedisConfiguration) - The `RedisConfiguration`. ``` -------------------------------- ### RedisConfiguration Constructors Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Redis.RedisConfiguration.html Provides information on how to initialize the RedisConfiguration class, with different overloads available for various configuration needs. ```APIDOC ## RedisConfiguration() ### Description Initializes a new instance of the RedisConfiguration class. ### Method Constructor ### Parameters None ``` ```APIDOC ## RedisConfiguration(string key, IList endpoints, int database = 0, string password = null, bool isSsl = false, string sslHost = null, int connectionTimeout = 5000, bool allowAdmin = false, bool keyspaceNotificationsEnabled = false, bool twemproxyEnabled = false, string strictCompatibilityModeVersion = null) ### Description Initializes a new instance of the RedisConfiguration class with detailed connection parameters. ### Method Constructor ### Parameters #### Path Parameters - **key** (String) - Required - The configuration key which will be used by the cache handle to find a configuration for the cache handle's name. - **endpoints** (IList) - Required - The list of ServerEndPoint s to be used to connect to Redis server. - **database** (Int32) - Optional - The Redis database index. - **password** (String) - Optional - The password of the Redis server. - **isSsl** (Boolean) - Optional - If `true` instructs the cache to use SSL encryption. - **sslHost** (String) - Optional - If specified, the connection will set the SSL host. - **connectionTimeout** (Int32) - Optional - Sets the timeout used for connect operations. - **allowAdmin** (Boolean) - Optional - If set to `True` it enables the cache to use features which might be risky. `Clear` for example. - **keyspaceNotificationsEnabled** (Boolean) - Optional - Enables keyspace notifications to react on eviction/expiration of items. - **twemproxyEnabled** (Boolean) - Optional - Enables Twemproxy mode. - **strictCompatibilityModeVersion** (String) - Optional - Gets or sets a version number to eventually reduce the avaible features accessible by cachemanager. ``` ```APIDOC ## RedisConfiguration(string key, string connectionString, int database = 0, bool keyspaceNotificationsEnabled = false, string strictCompatibilityModeVersion = null) ### Description Initializes a new instance of the RedisConfiguration class using a connection string. ### Method Constructor ### Parameters #### Path Parameters - **key** (String) - Required - The configuration key which will be used by the cache handle to find a configuration for the cache handle's name. - **connectionString** (String) - Required - Instead of specifying all the properties, this can also be done via one connection string. - **database** (Int32) - Optional - The redis database to use. - **keyspaceNotificationsEnabled** (Boolean) - Optional - Enables keyspace notifications to react on eviction/expiration of items. - **strictCompatibilityModeVersion** (String) - Optional - Gets or sets a version number to eventually reduce the avaible features accessible by cachemanager. ``` -------------------------------- ### Get Method Declaration Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Web.CacheManagerOutputCacheProvider.html Declares the Get method for retrieving an entry from the output cache. ```csharp public override object Get(string key) ``` -------------------------------- ### Get Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.ICache-1.html Gets a value for the specified key and region and will cast it to the specified type. ```APIDOC ## Get(String, String) ### Description Gets a value for the specified key and region and will cast it to the specified type. ### Method Not specified (likely returns a value). ### Endpoint Not applicable (SDK method). ### Parameters #### Path Parameters None. #### Query Parameters None. #### Request Body None. ### Parameters - **key** (String) - Required - The key being used to identify the item within the cache. - **region** (String) - Required - The cache region. ### Returns - **TOut**: The value being stored in the cache for the given key and region. ### Type Parameters - **TOut**: The type the cached value should be converted to. ### Exceptions - **ArgumentNullException**: If the key or region is null. - **InvalidCastException**: If no explicit cast is defined from `TCacheValue` to `TOut`. ``` -------------------------------- ### Initialize Method Declaration Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Web.CacheManagerOutputCacheProvider.html Declares the Initialize method for setting up the provider with configuration. ```csharp public override void Initialize(string name, NameValueCollection config) ``` -------------------------------- ### Get(String, String) Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.Internal.BaseCache-1.html Gets a value from a specific cache region using the specified key. ```APIDOC ## Get(String, String) ### Description Gets a value from a specific cache region using the specified key. ### Method GET ### Endpoint /api/cache/{region}/{key} ### Parameters #### Path Parameters - **key** (String) - Required - The key being used to identify the item within the cache. - **region** (String) - Required - The cache region. ### Response #### Success Response (200) - **Value** (TCacheValue) - The value being stored in the cache for the given key and region. ``` -------------------------------- ### Cache Operations: Add and AddOrUpdate Source: https://cachemanager.michaco.net/documentation/CacheManagerLogging Demonstrates the trace logs for 'Add' and 'AddOrUpdate' cache operations. 'Add' logs success, while 'AddOrUpdate' shows failure to add due to existing key, followed by a successful update. ```csharp cache.Add("key", "value"); cache.AddOrUpdate("key", "value", _ => "update value", 22); ``` ```text CacheManager.Core.BaseCacheManager: Trace: Add: key CacheManager.Core.BaseCacheManager: Trace: Add: successfully added key to handle redis CacheManager.Core.BaseCacheManager: Trace: Add: successfully added key to handle default CacheManager.Core.BaseCacheManager: Trace: Add or update: key . CacheManager.Core.BaseCacheManager: Trace: Add: key CacheManager.Core.BaseCacheManager: Trace: Add: key to handle redis FAILED. Evicting items from other handles. CacheManager.Core.BaseCacheManager: Trace: Evict from other handles: key : excluding handle 1. CacheManager.Core.BaseCacheManager: Trace: Evict from handle: key : on handle default. CacheManager.Core.BaseCacheManager: Trace: Add or update: key : add failed, trying to update... CacheManager.Core.BaseCacheManager: Trace: Update: key . CacheManager.Core.BaseCacheManager: Trace: Update: key : tried on handle redis: result: Success. CacheManager.Core.BaseCacheManager: Trace: Evict from handles above: key : above handle 1. CacheManager.Core.BaseCacheManager: Trace: Evict from handle: key : on handle default. CacheManager.Core.BaseCacheManager: Trace: Add to handles below: key : below handle 1. CacheManager.Core.BaseCacheManager: Trace: Add or update: key : successfully updated. ``` -------------------------------- ### Install CacheManager Microsoft Extensions Logging Source: https://cachemanager.michaco.net/ Installs the Microsoft Extensions Logging integration for CacheManager. ```powershell Install-Package CacheManager.Microsoft.Extensions.Logging ``` -------------------------------- ### Install CacheManager Microsoft Extensions Configuration Source: https://cachemanager.michaco.net/ Installs the Microsoft Extensions Configuration integration for CacheManager. ```powershell Install-Package CacheManager.Microsoft.Extensions.Configuration ``` -------------------------------- ### Initialize CouchbaseConfigurationManager Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Couchbase.CouchbaseConfigurationManager.html Initializes a new instance of the CouchbaseConfigurationManager class with a configuration key, bucket name, and bucket password. ```csharp public CouchbaseConfigurationManager(string configurationKey, string bucketName = "default", string bucketPassword = null) ``` -------------------------------- ### Get(String, String) Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Core.ICache-1.html Gets a value for the specified key and region and will cast it to the specified type. ```APIDOC ## Get(String, String) ### Description Gets a value for the specified key and region and will cast it to the specified type. ### Method TOut Get(string key, string region) ### Endpoint N/A (SDK Method) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Parameters #### Path Parameters - **key** (string) - Required - The key being used to identify the item within the cache. - **region** (string) - Required - The cache region. ### Type Parameters - **TOut** (Type) - The type the cached value should be converted to. ### Returns #### Success Response - **TOut**: The value being stored in the cache for the given key and region. ### Exceptions - **ArgumentNullException**: If the key or region is null. - **InvalidCastException**: If no explicit cast is defined from `TCacheValue` to `TOut`. ``` -------------------------------- ### Initialize CacheHandleConfiguration with Name and Key Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.CacheHandleConfiguration.html Initializes a new instance of the CacheHandleConfiguration class with a handle name and a configuration key. The configuration key can be used to identify other configuration parts needed by the handle. ```csharp public CacheHandleConfiguration(string handleName, string configurationKey) ``` -------------------------------- ### SystemWebCacheHandle.Context Property Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Web.SystemWebCacheHandle-1.html Gets the HttpContextBase being used to get the Cache instance. This implementation requires HttpContext.Current to be not null. ```csharp protected virtual HttpContextBase Context { get; } ``` -------------------------------- ### OnGet Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Core.Internal.CacheStats-1.html Callback invoked when a cache Get operation is performed. This method can be overridden to track or modify Get requests. ```APIDOC ## OnGet ### Description Callback invoked when a cache Get operation is performed. This method can be overridden to track or modify Get requests. ### Method `OnGet(string region = null)` ### Parameters #### Path Parameters - **region** (string) - Optional - The name of the cache region from which the item was requested. If null, it applies to the entire cache. ``` -------------------------------- ### LoadConfiguration from web.config/app.config with Section Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.ConfigurationBuilder.html Loads a configuration from the default web.config or app.config file, specifying both the section name and the cache element name. The configName must match an existing cache element. ```csharp public static ICacheManagerConfiguration LoadConfiguration(string sectionName, string configName) ``` -------------------------------- ### SystemWebCacheHandle.Context Property Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Web.SystemWebCacheHandle-1.html Gets the http context being used to get the `Cache` instance. This implementation requires Current to be not null. ```APIDOC ## Context Property ### Description Gets the http context being used to get the `Cache` instance. This implementation requires Current to be not null. ### Property Value - **HttpContextBase** - The http context instance. ``` -------------------------------- ### Get or Set Item by Key Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.ICache-1.html Accesses a cache item using its key. This indexer is equivalent to Put and Get calls for a specific key. ```csharp TCacheValue this[string key] { get; set; } ``` -------------------------------- ### ServerEndPoint Constructors Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Redis.ServerEndPoint.html Provides information on how to initialize a ServerEndPoint object. ```APIDOC ## ServerEndPoint() ### Description Initializes a new instance of the ServerEndPoint class. ### Method Constructor ### Parameters None ### Response Example ```json { "message": "ServerEndPoint object initialized" } ``` ## ServerEndPoint(String, Int32) ### Description Initializes a new instance of the ServerEndPoint class with a specified host and port. ### Method Constructor ### Parameters #### Path Parameters - **host** (String) - Required - The host. - **port** (Int32) - Required - The port. ### Exceptions - **ArgumentNullException**: If host is null. ### Response Example ```json { "message": "ServerEndPoint object initialized with host and port" } ``` ``` -------------------------------- ### CacheManager Get Operation Trace Logs Source: https://cachemanager.michaco.net/documentation/cachemanager_logging Trace logs for a Get operation, showing item lookup status across different cache handles and subsequent re-addition. ```text CacheManager.Core.BaseCacheManager: Trace: Get: key . CacheManager.Core.BaseCacheManager: Trace: Get: key : item NOT found in handle default. CacheManager.Core.BaseCacheManager: Trace: Get: key : item found in handle redis. CacheManager.Core.BaseCacheManager: Trace: Add to handles: key : with update mode Up. CacheManager.Core.BaseCacheManager: Trace: Add to handles: key : adding to handle 0. ``` -------------------------------- ### PutInternalPrepared Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Core.Internal.BaseCacheHandle-1.html Puts the item into the cache after preparation. If the item exists, it will be updated; otherwise, it will be added. ```APIDOC ## PutInternalPrepared(CacheItem) ### Description Puts the item into the cache after preparation. If the item exists, it will be updated; otherwise, it will be added. ### Method protected abstract ### Parameters #### Path Parameters - **item** (CacheItem) - Required - The `CacheItem` to be added to the cache. ``` -------------------------------- ### BaseCache Indexers Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Core.Internal.BaseCache-1.html The BaseCache class provides indexers to get and set cache items using a key, and optionally a region. These indexers delegate to the Put and Get methods. ```APIDOC ## BaseCache Indexers ### Description Provides indexers to get and set cache items by key, and optionally by key and region. These indexers delegate to the corresponding Put and Get methods. ### Item[String] Gets or sets a value for the specified key. This is identical to calling `Put(key, value)` and `Get(key)`. #### Parameters - **key** (string) - The key being used to identify the item within the cache. #### Property Value - **TCacheValue** - The value being stored in the cache for the given key. #### Exceptions - **ArgumentNullException** - If the key is null. ### Item[String, String] Gets or sets a value for the specified key and region. This is identical to calling `Put(key, value, region)` and `Get(key, region)`. With region specified, the key will not be found in the global cache. #### Parameters - **key** (string) - The key being used to identify the item within the cache. - **region** (string) - The cache region. #### Property Value - **TCacheValue** - The value being stored in the cache for the given key and region. #### Exceptions - **ArgumentNullException** - If the key or region is null. ``` -------------------------------- ### Get Element Key for Configuration Element Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Core.Configuration.CacheHandleDefinitionCollection.html Gets the element key for a specified configuration element when overridden in a derived class. This method is crucial for identifying and retrieving specific elements within the collection. ```csharp protected override object GetElementKey(ConfigurationElement element) { // Implementation would typically involve casting the element to its specific type // and returning a unique property like a name or key. // Example: // return ((CacheHandleDefinition)element).Name; return null; // Placeholder, actual implementation depends on CacheHandleDefinition structure ``` -------------------------------- ### Configure Single Cache Handle Source: https://cachemanager.michaco.net/documentation/CacheManagerArchitecture Example of configuring a CacheManager instance with a single System.Runtime.Caching handle using the ConfigurationBuilder. ```csharp var cache = CacheFactory.Build("myCacheName", settings => { settings .WithSystemRuntimeCacheHandle("handle1"); }); ``` -------------------------------- ### Cache Operation: Get Trace Log Source: https://cachemanager.michaco.net/documentation/CacheManagerLogging This trace log details the 'Get' operation for a cache key, showing attempts to retrieve the item from different handles and its eventual success from the Redis handle. ```csharp var val = cache.Get("key"); ``` ```text CacheManager.Core.BaseCacheManager: Trace: Get: key . CacheManager.Core.BaseCacheManager: Trace: Get: key : item NOT found in handle default. CacheManager.Core.BaseCacheManager: Trace: Get: key : item found in handle redis. CacheManager.Core.BaseCacheManager: Trace: Add to handles: key : with update mode Up. CacheManager.Core.BaseCacheManager: Trace: Add to handles: key : adding to handle 0. ``` -------------------------------- ### Item[String] Indexer Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.Internal.BaseCache-1.html Gets or sets a value for the specified key. This indexer is identical to the corresponding Put(String, TCacheValue) and Get(String) calls. It allows direct access to cache items using a string key. ```APIDOC ## Item[String] Indexer ### Description Gets or sets a value for the specified key. The indexer is identical to the corresponding Put(String, TCacheValue) and Get(String) calls. ### Declaration ```csharp public virtual TCacheValue this[string key] { get; set; } ``` ### Parameters - **key** (String) - The key being used to identify the item within the cache. ### Property Value - **TCacheValue**: The value being stored in the cache for the given key. ### Implements ICache.Item[String] ### Exceptions - **ArgumentNullException**: If the key is null. ``` -------------------------------- ### Build(Action settings) Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.CacheFactory.html Instantiates a cache manager with Object as the cache item type using inline configuration settings. ```APIDOC ## Build(Action settings) ### Description Instantiates a cache manager using the inline configuration defined by settings. This Build method returns an ICacheManager with cache item type being Object. ### Method static ICacheManager Build(Action settings) ### Parameters #### Parameters - **settings** (Action) - Required - The configuration. Use the settings element to configure the cache manager instance, add cache handles and also to configure the cache handles in a fluent way. ### Returns - **ICacheManager** - The cache manager instance. ### Exceptions - **ArgumentNullException** - Thrown if settings is null. - **InvalidOperationException** - Thrown on certain configuration errors related to the cache handles. ### Examples ```csharp var cache = CacheFactory.Build(settings => { settings .WithUpdateMode(CacheUpdateMode.Up) .WithDictionaryHandle() .EnablePerformanceCounters() .WithExpiration(ExpirationMode.Sliding, TimeSpan.FromSeconds(10)); }); cache.Add("key", "value"); ``` ``` -------------------------------- ### TypeCache.ObjectType Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.Internal.TypeCache.html Gets the System.Type representation of object. ```APIDOC ## Property: ObjectType ### Description Gets `typeof(object)`. ### Declaration ``` public static Type ObjectType { get; } ``` ### Property Value - **Type** (Type) - Description: Type ``` -------------------------------- ### Create Another Cache Manager with Reused Configuration Source: https://cachemanager.michaco.net/documentation/CacheManagerConfiguration Demonstrates reusing a previously built configuration object to create a new cache manager instance, potentially for a different data type. ```csharp var cache = CacheFactory.FromConfiguration("numbers", cfg); ``` -------------------------------- ### Initialize ServerEndPoint with Default Values Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Redis.ServerEndPoint.html Use the default constructor to create an instance of ServerEndPoint without specifying host or port initially. Properties can be set later. ```csharp public ServerEndPoint() ``` -------------------------------- ### GetCacheItem Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.ICache-1.html Gets the `CacheItem` for the specified key. ```APIDOC ## GetCacheItem(String) ### Description Gets the `CacheItem` for the specified key. ### Method Not specified (likely returns a CacheItem). ### Endpoint Not applicable (SDK method). ### Parameters #### Path Parameters None. #### Query Parameters None. #### Request Body None. ### Parameters - **key** (String) - Required - The key being used to identify the item within the cache. ### Returns - **CacheItem**: The `CacheItem`. ### Exceptions - **ArgumentNullException**: If the key is null. ``` -------------------------------- ### MemcachedCacheHandle Constructor (with MemcachedClient) Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Memcached.MemcachedCacheHandle-1.html Initializes a new instance of the MemcachedCacheHandle class using a pre-configured Enyim MemcachedClient instance. This is beneficial when the client needs to be managed or shared externally. ```csharp public MemcachedCacheHandle(ICacheManagerConfiguration managerConfiguration, CacheHandleConfiguration configuration, ILoggerFactory loggerFactory, ICacheSerializer serializer, MemcachedClient client) ``` -------------------------------- ### GetCacheItem(String) Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Core.ICache-1.html Gets the `CacheItem` for the specified key. ```APIDOC ## GetCacheItem(String) ### Description Gets the `CacheItem` for the specified key. ### Method CacheItem GetCacheItem(string key) ### Endpoint N/A (SDK Method) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Parameters #### Path Parameters - **key** (string) - Required - The key being used to identify the item within the cache. ### Returns #### Success Response - **CacheItem**: The `CacheItem`. ### Exceptions - **ArgumentNullException**: If the key is null. ``` -------------------------------- ### Basic Cache Operations: Add, Put, Update, Get, Remove Source: https://cachemanager.michaco.net/documentation/CacheManagerGettingStarted Demonstrates fundamental CacheManager operations including adding items, putting/updating values, retrieving items by key, and removing items. This code assumes a cache instance has already been built. ```csharp cache.Add("keyA", "valueA"); cache.Put("keyB", 23); cache.Update("keyB", v => 42); ``` ```csharp Console.WriteLine("KeyA is " + cache.Get("keyA")); // should be valueA Console.WriteLine("KeyB is " + cache.Get("keyB")); // should be 42 cache.Remove("keyA"); Console.WriteLine("KeyA removed? " + (cache.Get("keyA") == null).ToString()); ``` -------------------------------- ### BaseCacheManager.Configuration Property Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Core.BaseCacheManager-1.html Gets the read-only configuration of the BaseCacheManager. ```APIDOC ## Configuration ### Description Gets the read-only configuration of the cache manager. ### Property Value - **IReadOnlyCacheManagerConfiguration** - The cache manager configuration. ### Implements ICacheManager.Configuration ``` -------------------------------- ### GetCacheItem Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.ICache-1.html Gets the `CacheItem` for the specified key and region. ```APIDOC ## GetCacheItem(String, String) ### Description Gets the `CacheItem` for the specified key and region. ### Method Not specified (likely returns a CacheItem). ### Endpoint Not applicable (SDK method). ### Parameters #### Path Parameters None. #### Query Parameters None. #### Request Body None. ### Parameters - **key** (String) - Required - The key being used to identify the item within the cache. - **region** (String) - Required - The cache region. ### Returns - **CacheItem**: The `CacheItem`. ``` -------------------------------- ### Initialize CacheHandleConfiguration Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.CacheHandleConfiguration.html Initializes a new instance of the CacheHandleConfiguration class with default settings. ```csharp public CacheHandleConfiguration() ``` -------------------------------- ### CacheItem Value Property Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.CacheItem-1.html Gets the cached value. ```csharp public T Value { get; } ``` -------------------------------- ### LoadConfigurationFile from a specific file and section Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.ConfigurationBuilder.html Loads a configuration from a specified file path and section name, using a given cache element name. The configName must match an existing cache element within the specified section of the file. Throws ArgumentNullException if file path or config name is null, and InvalidOperationException if the file does not exist. ```csharp public static ICacheManagerConfiguration LoadConfigurationFile(string configFileName, string sectionName, string configName) ``` -------------------------------- ### CacheManager Initialization Logs Source: https://cachemanager.michaco.net/documentation/CacheManagerLogging These logs indicate the initialization process of the CacheManager, including the addition of cache handles. ```text CacheManager.Core.BaseCacheManager: Information: Cache manager: adding cache handles... CacheReflectionHelper: Information: Creating handle sys cache. CacheReflectionHelper: Information: Creating handle d410accc-53ed-44ac-929f-a213f1503128. ``` -------------------------------- ### Name Property Declaration Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.IReadOnlyCacheManagerConfiguration.html Gets the name of the cache. ```csharp string Name { get; } ``` -------------------------------- ### RedisConfigurationBuilder Constructors Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Redis.RedisConfigurationBuilder.html Initializes a new instance of the RedisConfigurationBuilder class. ```APIDOC ## RedisConfigurationBuilder(String) ### Description Initializes a new instance of the RedisConfigurationBuilder class. ### Parameters #### Path Parameters - **configurationKey** (string) - Required - The configuration key. ### Exceptions - **ArgumentNullException**: If configurationKey is null. ``` -------------------------------- ### Item[String, String] Indexer Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.Internal.BaseCache-1.html Gets or sets a value for the specified key and region. This indexer is identical to the corresponding Put(String, TCacheValue, String) and Get(String, String) calls. Items accessed with a region specified will not be found in the global cache. ```APIDOC ## Item[String, String] Indexer ### Description Gets or sets a value for the specified key and region. The indexer is identical to the corresponding Put(String, TCacheValue, String) and Get(String, String) calls. With region specified, the key will **not** be found in the global cache. ### Declaration ```csharp public virtual TCacheValue this[string key, string region] { get; set; } ``` ### Parameters - **key** (String) - The key being used to identify the item within the cache. - **region** (String) - The cache region. ### Property Value - **TCacheValue**: The value being stored in the cache for the given key and region. ### Implements ICache.Item[String, String] ### Exceptions - **ArgumentNullException**: If the key or region is null. ``` -------------------------------- ### BondSerializerBase Constructor (Default) Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Serialization.Bond.BondSerializerBase.html Initializes a new instance of the BondSerializerBase class with default settings. No parameters are required. ```csharp public BondSerializerBase() ``` -------------------------------- ### BaseCacheManager.Name Property Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Core.BaseCacheManager-1.html Gets the name of the cache managed by BaseCacheManager. ```APIDOC ## Name ### Description Gets the name of the cache. ### Property Value - **String** - The name of the cache. ### Implements ICacheManager.Name ``` -------------------------------- ### LoadConfiguration from web.config/app.config Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.ConfigurationBuilder.html Loads a configuration from the default web.config or app.config file using a specified cache element name. Ensure the configName matches an existing cache element. ```csharp public static ICacheManagerConfiguration LoadConfiguration(string configName) ``` -------------------------------- ### RedisConfigurationBuilder Constructor Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Redis.RedisConfigurationBuilder.html Initializes a new instance of the RedisConfigurationBuilder class with a specified configuration key. ```APIDOC ## RedisConfigurationBuilder(String) ### Description Initializes a new instance of the RedisConfigurationBuilder class. ### Method Constructor ### Parameters #### Path Parameters - **configurationKey** (String) - Required - The configuration key. ### Exceptions - **ArgumentNullException**: If configurationKey is null. ``` -------------------------------- ### BaseCacheManager.Logger Property Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Core.BaseCacheManager-1.html Gets the logger instance used by the BaseCacheManager. ```APIDOC ## Logger ### Description Gets the logger instance used by the cache manager. ### Property Value - **ILogger** - The logger instance. ### Overrides CacheManager.Core.Internal.BaseCache.Logger ``` -------------------------------- ### BaseCacheManager.Backplane Property Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Core.BaseCacheManager-1.html Gets the configured cache backplane for the BaseCacheManager. ```APIDOC ## Backplane ### Description Gets the configured cache backplane. ### Property Value - **CacheBackplane** - The backplane. ``` -------------------------------- ### Configure Backplane with Type, Key, and Channel Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.ConfigurationBuilderCachePart.html Configures an optional backplane with a specified channel name for cache synchronization. This overload requires a configuration key and channel name. ```csharp public ConfigurationBuilderCachePart WithBackplane(Type backplaneType, string configurationKey, string channelName, params object[] args) ``` -------------------------------- ### Logger Property Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Redis.RedisCacheHandle-1.html Gets the logger instance for this cache handle. ```APIDOC ## Logger Property ### Description Gets the logger instance for this cache handle. ### Property Value - **ILogger** - The logger instance. ### Overrides BaseCacheManager.Core.BaseCache.Logger ``` -------------------------------- ### Features Property Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Redis.RedisCacheHandle-1.html Gets the features supported by the Redis server. ```APIDOC ## Features Property ### Description Gets the features the redis server supports. ### Property Value - **RedisFeatures** - The server features. ``` -------------------------------- ### CacheBackplane Constructor Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.Internal.CacheBackplane.html Initializes a new instance of the CacheBackplane class. Throws ArgumentNullException if the configuration is null. ```csharp protected CacheBackplane(ICacheManagerConfiguration configuration) ``` -------------------------------- ### Create Cache Manager from Configuration Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.CacheFactory.html Instantiates a cache manager using configuration settings from app/web.config. Requires the cache name and section name. You can then add items to the cache. ```csharp var cache = CacheFactory.FromConfiguration("cache", "section"); cache.Add("key", "value"); ``` -------------------------------- ### SslHost Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Redis.RedisOptions.html Gets or sets the SSL host. This property is optional. ```APIDOC ## SslHost ### Description Gets or sets the SSL host. ### Declaration ```csharp [ConfigurationProperty("sslHost", IsRequired = false)] public string SslHost { get; set; } ``` ### Property Value Type | Description ---|--- String | The SSL host. ``` -------------------------------- ### WithRedisConfiguration (Action) Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Core.RedisConfigurationBuilderExtensions.html Adds a Redis configuration using a configuration key and an action to configure the Redis settings. ```APIDOC ## WithRedisConfiguration(ConfigurationBuilderCachePart, String, Action) ### Description Adds a redis configuration with the given configurationKey. ### Method Extension Method ### Parameters #### Path Parameters - **part** (ConfigurationBuilderCachePart) - Required - The builder instance. - **configurationKey** (String) - Required - The configuration key which can be used to refernce this configuration by a redis cache handle or backplane. - **configuration** (Action) - Required - The redis configuration object. ### Returns #### Success Response - **ConfigurationBuilderCachePart** - The configuration builder. ### Exceptions - **ArgumentNullException** - If configuration or configurationKey are null. ``` -------------------------------- ### BackplaneChannelName Property Declaration Source: https://cachemanager.michaco.net/Documentation/api/CacheManager.Core.IReadOnlyCacheManagerConfiguration.html Gets the backplane channel name. ```csharp string BackplaneChannelName { get; } ``` -------------------------------- ### Servers Property Source: https://cachemanager.michaco.net/documentation/api/CacheManager.Memcached.MemcachedCacheHandle-1.html Gets a list of the IP endpoints for the Memcached servers. ```APIDOC ## Servers Property ### Description Gets the list of Memcached server endpoints. ### Property `public IList Servers { get; }` ### Returns - **IList** - A list of IP endpoints representing the Memcached servers. ```