Memcached is a high-performance, distributed memory object caching system. Redakt offers Memcached integration through an optional NuGet package. Memcached is only suitable for very large distributed applications with many nodes. For most applications, the in-memory cache together with a distributed service bus is a better performing setup.

Installation

Install the Memcached package with the NuGet package manager or the Package Manager Console.

PM> Install-Package Redakt.Providers.Memcached

Service registration

Register Memcached services in the ConfigureServices() method of your project's Startup.cs file by adding an AddMemcached() call to the Redakt builder instance. The order in which services are added to the Redakt builder is not important.

public void ConfigureServices(IServiceCollection services)
{
    // ... framework and other services here

    var builder = services.AddRedakt();
    builder.AddMemcached();  // Optionally pass Action<MemcachedCacheOptions> parameter.
    // ... other Redakt services
}

Configuration settings

The Memcached cache is configured through the appsettings.json file. Any configuration that is not included in the appsettings.json file will be set to its default values. Additionally, an Action<MemcachedCacheOptions> configuration delegate may be passed to the AddMemcached() call. Configuration set through this delegate takes priority and overrides values in the appsettings.json file.

{
    "Redakt": {
        "ApplicationCache": {
            "Memcached": {
                "ServerHostname": "<your memcached hostname>",
                "ServerPort": 8080,
                "Username": "<your memcached username>",
                "Password": "<your memcached password>",
                "CacheExpirationSeconds": 300,
            }
        }
    }
}

Server Hostname

Required. Sets the server hostname for the Memcached service.

Server Port

Sets the server port for the Memcached service. Defaults to 8080 if not specified.

Username

Required. Sets the username for the account that is used to connect to the Memcached service.

Password

Required. Sets the password for the account that is used to connect to the Memcached service.

Cache Expiration

Sets the expiration time in seconds before cache items are purged from the cache. Defaults to 300 (5 minutes) if not set.