SlimMemoryCacheOptions Class
Definition
- Assemblies
- Cuemon.Runtime.Caching.dll
Configuration options for SlimMemoryCache.
public class SlimMemoryCacheOptions : IValidatableParameterObject, IParameterObject
- Inheritance
-
SlimMemoryCacheOptions
- Implements
Examples
The following example demonstrates how to configure
using System;
using Cuemon.Runtime.Caching;
namespace MyApp.Examples;
public static class SlimMemoryCacheOptionsExample
{
public static void Demonstrate()
{
var options = new SlimMemoryCacheOptions
{
EnableCleanup = false,
FirstSweep = TimeSpan.FromSeconds(10),
SucceedingSweep = TimeSpan.FromSeconds(30),
KeyProvider = (key, ns) => key.Length + (ns == CacheEntry.NoScope ? 0 : ns.Length)
};
options.ValidateOptions();
Console.WriteLine(options.EnableCleanup);
Console.WriteLine(options.FirstSweep);
Console.WriteLine(options.KeyProvider("session", "docs"));
}
}
Constructors
| Name | Description |
|---|---|
| SlimMemoryCacheOptions() | Initializes a new instance of the SlimMemoryCacheOptions class. |
Properties
| Name | Description |
|---|---|
| EnableCleanup | Gets or sets a value indicating whether a periodic sweep clean-up is done on the cache. |
| FirstSweep | Gets or sets the TimeSpan that specifies the amount of time to wait before the initial first sweep clean-up. |
| KeyProvider | Gets or sets the function delegate that is responsible for providing a unique identifier for a cache entry. |
| SucceedingSweep | Gets or sets the TimeSpan that specifies the interval for every succeeding sweep clean-up after the initial FirstSweep. |
Methods
| Name | Description |
|---|---|
| ValidateOptions() | Determines whether the public read-write properties of this instance are in a valid state. |