In-Memory Cache

This is the default application cache implementation, included in the core package. The In-Memory cache module caches objects in memory of the local server instance. In a load-balanced scenario, a distributed cache may be better suited to reduce data store requests (but not required if a distributed service bus is used).

Installation

The In-Memory cache module is part of the Redakt Core and does not need to be installed separately. The module will be registered by default if no other application cache module has been registered.

Configuration

The In-Memory cache is configured through the appsettings.json file. Any configuration that is not included in the appsettings.json file will be set to its following default values.

{
    "Redakt": {
        "ApplicationCache": {
            "InMemory": {
                "SlidingExpirationSeconds": 300,
                "AbsoluteExpirationSeconds": 3600,
                "CacheInvalidationDelayMilliseconds": 0
            }
        }
    }
}

Sliding Expiration

Sets the sliding cache expiration in seconds. A cache item will be purged from the cache if it hasn't been requested for this amount of time. Setting a lower value will reduce memory usage but may result in a higher data store load. Defaults to 300 (5 minutes) if not set.

Absolute Expiration

Sets the absolute cache expiration in seconds. After this time a cache item will always be purged from the cache, no matter how often it is requested. Defaults to 3600 (1 hour) if not set.

Cache Invalidation Delay

Sets the delay in milliseconds before a cache item is purged from the cache after an invalidation event. This is useful when using an eventually-consistent data store, where an immediate subsequent request from the data store may retrieve and cache a stale object.