> For the complete documentation index, see [llms.txt](https://docs.eiffel.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eiffel.dev/features/caching/configuration/in-memory.md).

# In-Memory

In-Memory cache provides own configuration properties. For configuration details please [visit](/features/caching/api/inmemorycacheoptions.md).

You can configure values from appsettings.json file

```json
{
    "Caching": {
        "Source": "InMemory",
        "InMemory": {
           "TrackStatistics": true,
           "ExpirationScanFrequencyInSeconds" : 30
        }
    }
}
```

If you need to advanced configuration or configure cache service without appsettings.json file. You can use extension method.

AddCaching method initally read values from appsettings.json file afterwards applies configuration from action method.

```csharp
// Program.cs (.NET5 and above)
public static async Task Main(string[] args)
{
    var builder = WebApplication.CreateBuilder(args);
    
    // Add with configuration instance
    var cacheOptions = new InMemoryCacheOptions();
    cacheOptions.ExpirationScanFrequencyInSeconds = 30;
    cacheOptions.Clock = new CustomSystemClock(); // Your custom ISystemClock implementation.
    builder.AddCaching(x => x.InMemory(cacheOptions));

    // Add with inline action method
    builder.AddCaching(x => x.InMemory(x => x.ExpirationScanFrequencyInSeconds = 120));
 
    var app = builder.Build();
    app.Run();
}
```
