Skip to content

Add implementation of IDistributedCache and HybridCache #591

@jeastham1993

Description

@jeastham1993

.NET has built in abstractions for caching. Namely IDistributedCache and in .NET 9 the new HybridCache.

Caching services like Redis add an implementation of the IDistributedCache interface making it easy to add Redis by adding a dependency on Microsoft.Extensions.Caching.StackExchangeRedis and adding the following code to the application startup.

builder.Services.AddStackExchangeRedisCache(options =>
{
    options.Configuration = builder.Configuration["RedisConnectionString"];
    options.InstanceName = "Orders";
});

This also makes it easy to switch out caching technologies, for example using an InMemory cache when working locally and Redis when running in production.

It would be great if Momento can add support, with syntax similar to:

builder.Services.AddMomentoCache(options =>
{
    options.ApiKey = builder.Configuration["MomentoApiKey"];
    options.CacheName = "Orders";
});

I have a working example of this, if you can let me know the best way to contribute my implementation I can raise a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions