ASP.NET Core Distributed Cache Library

The Scaleout.AspNetCore NuGet package provides an ASP.NET Core IDistributedCache implementation for use with ScaleOut Software’s in-memory data grid products. In addition to caching, an IDistributedCache implementation is used as a backing store for session state in ASP.NET Core.

Prerequisites

  • One or more instances of the ScaleOut SessionServer or StateServer service (either local or remote).

  • .NET Core 2.1 or higher.

Configuration

  1. Install this NuGet package and its dependencies:

    Install-Package Scaleout.AspNetCore
    
  2. Modify your application settings and add the following configuration elements, replacing the example configuration values as appropriate to your environment (Configuration elements are described in further detail later in this document):

    Modify the ScaleOutStateServer element in your application settings to supply configuration values. For example:

    "ScaleOutStateServer": {
      "connectionString": "bootstrapGateways=192.168.1.42:721,192.168.1.43:721;maxRequestRetries=2",
      "defaultNamespace": "My cache namespace"
    }
    
  3. In your app’s Startup.cs file, add the following lines to the ConfigureServices(IServiceCollection) method:

    public void ConfigureServices(IServiceCollection services)
    {
        // Add framework services.
        // ...
        services.AddSession();
    
        // Add ScaleOut implementation of IDistributedCache.
        services.AddScaleoutDistributedCache(Configuration);
    
        // ...
    }
    

    Note: If your configuration file uses a different name than “ScaleOutStateServer” for the configuration element, you may use the AddScaleoutDistributedCache(ConfigurationSection) overload:

    services.AddScaleoutDistributedCache(Configuration.GetSection("MyScaleOutConfigurationSection"))
    

Provider Settings

  • connectionString: String containing information for connecting to ScaleOut service, as described in the Connecting to a ScaleOut Data Grid topic.

  • defaultNamespace: (String) The name of the application namespace to use in the ScaleOut StateServer in-memory data grid.

  • maxSerializedCacheMemory: (Integer, optional) The maximum size (in bytes) of the serialized network cache held in the client memory process to minimize data transfer to and from the ScaleOut StateServer service when the client is internally known to be working with the latest version of a ScaleOut StateServer data grid object. Default: 10 MB.

  • protocol (String, optional) The protocol to use when communicating between the client application and the ScaleOut StateServer service. Two protocols are currently supported:

    • SossTcpTransport (default): Connects directly to the ScaleOut service. Offers the best performance.

    • SossHttpTransport (deprecated): Communicates to the ScaleOut StateServer service over HTTP via the ScaleOut REST API service.

  • CoherencyInterval: (Double, optional) The maximum amount of time (in seconds) that can elapse before the client library performs a round-trip to the authoritative ScaleOut service. During this interval, a requested object can be returned directly from the in-process cache, which results in very good performance, but the returned value could be stale. The default value is 0 seconds (the cache is fully coherent).