Skip to content

[FEATURE] Add WithOptions overload that supports resolving services via IServiceProvider #605

Description

@petriceko

Problem

We need to dynamically configure CacheKeyPrefix based on a service (ICachePrefixProvider) that may depend on runtime context (e.g., tenant, environment, or request-specific data).

Example

builder.Services.AddFusionCache()
    .WithOptions((sp, options) =>
    {
        var prefixProvider = sp.GetRequiredService<ICachePrefixProvider>();
        options.CacheKeyPrefix = prefixProvider.Prefix;
    })

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions