Skip to content

Split redis output-cache pieces from Microsoft.Extensions.Caching.StackExchange.Redis into Microsoft.AspNetCore.OutputCaching.StackExchangeRedis #50457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 11, 2023

Conversation

mgravell
Copy link
Member

Split redis output-cache pieces from Microsoft.Extensions.Caching.StackExchange.Redis into Microsoft.AspNetCore.OutputCaching.StackExchangeRedis

Description

Split SE.Redis OutputCache implementation into new package, Microsoft.AspNetCore.OutputCaching.StackExchangeRedis (it was causing an undesirable framework ref)

  • remove the output cache functionality and ref from Microsoft.Extensions.Caching.StackExchange.Redis
    • (simplified API [un]shipped.txt back to single; no change except no more unshipped)
  • moved functionality to new package (and update eng files accordingly)
  • new namespace etc; will need API review
  • in particular, RedisCacheOptions was shared between both APIs; now RedisOutputCacheOptions

Related: #50402

….AspNetCore.OutputCaching.StackExchangeRedis

(it was causing an undesirable framework ref)

- remove the output cache functionality and ref from Microsoft.Extensions.Caching.StackExchange.Redis
  - (simplified API [un]shipped.txt back to single; no change except no more unshipped)
- moved functionality to new package (and update eng files accordingly)
- new namespace etc; will need API review
- in particular, RedisCacheOptions was shared between both APIs; now RedisOutputCacheOptions
@ghost ghost added the area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares label Aug 31, 2023
@mgravell mgravell marked this pull request as ready for review September 1, 2023 15:14
@mgravell
Copy link
Member Author

mgravell commented Sep 1, 2023

oof, it really isn't happy about me monkeying with the shipped/unshipped files; I might have to revert that to prior state for now

does that look better @wtgodbe ?

@mgravell mgravell requested a review from wtgodbe September 1, 2023 15:31
Copy link
Member

@wtgodbe wtgodbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're good now - .Shipped.txt files should never be subtracted from, so that looks to be in good shape. CI will complain that the files were changed at all in a release/* branch, but in this case it's fine since it's RC2, so I can just force-merge this once it's good to go. Do you want anyone else to review it?

@BrennanConroy
Copy link
Member

Send an email to API review.

/// <summary>
/// Configuration options for Redis based output cache.
/// </summary>
public class RedisOutputCacheOptions : IOptions<RedisOutputCacheOptions>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way we can depend on the existing StackExchangeRedis package and share/derive from its options type and otherwise reduce duplication?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, yes. However, it seems an odd choice to take a package dependency just for a config definition.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I wanted a Distributed Cache and an Output Cache in my app that both talked to the same redis server, do I need to now configure them both the same way?

I wonder if we could put ConfigurationOptions as the thing that is an IOptions that I can configure. That way apps can configure redis distributed caches and redis output caches the same way and they compose together.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like a maintenance and config issue. E.g. having to add, implement, and configure options in both places.

I don't quite follow your suggestion @eerhardt. It would be nice to configure the two together somehow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite follow your suggestion

My suggestion is to use the StackExchange.Redis.ConfigurationOptions type as the "Options" object. That is what is configured in DI instead of these separate RedisOutputCacheOptions and RedisCacheOptions objects which have properties of type StackExchange.Redis.ConfigurationOptions.

One issue with IOptions is that they don't compose together well. You can't have have 2 IOptions objects that refer to the same instance without manually writing code to wire them together.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tratcher I 100% agree on the configure together thing; an option there is to use the option that provides the multiplexer directly, although that then doesn't have quite the same capability re recreating the connection; I suggest we tackle this in net9, though

/// <summary>
/// Configuration options for Redis based output cache.
/// </summary>
public class RedisOutputCacheOptions : IOptions<RedisOutputCacheOptions>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public class RedisOutputCacheOptions : IOptions<RedisOutputCacheOptions>
public class RedisOutputCacheOptions

This class doesn't need to implement IOptions. I know the existing distributed cache implements it, but I believe that is a mistake (that we can't fix because it is a shipped API).

Option classes are POCOs, and when someone consumes them in DI, that's when they use IOptions<XXX>.

For example:

public KestrelServerImpl(
IOptions<KestrelServerOptions> options,

public class KestrelServerOptions
{

KestrelServerOptions doesn't implement IOptions itself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did it in a few types like MemoryCache/Options where people would actually new up the options and class themselves. That's likely not the case here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tratcher so is that a "leave alone" or a "remove the IOptions"? happy with either

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove it. You don't new up a RedisOutputCache instance directly do you?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no; nuking, ta

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, it was probably there for the test; I switched them to use DI properly instead - sound like a plan? 7c915d4#diff-9b6a4cced77cfd298a082285b4f112b7e5a97059a80e5291df832b037e0e996a

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great.

@mgravell mgravell requested a review from JamesNK September 7, 2023 13:03
@mgravell
Copy link
Member Author

mgravell commented Sep 7, 2023

Now just needs someone like @wtgodbe or @adityamandaleeka to merge?

@wtgodbe
Copy link
Member

wtgodbe commented Sep 11, 2023

Re-running because of the helix failure

@wtgodbe wtgodbe merged commit c65d9a1 into release/8.0 Sep 11, 2023
@wtgodbe wtgodbe deleted the marc/oc_redis_lib_split_8_0 branch September 11, 2023 20:09
@ghost ghost added this to the 8.0-rc2 milestone Sep 11, 2023
@ghost ghost added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Sep 11, 2023
@mgravell
Copy link
Member Author

@wtgodbe is there anything magic we need to do to ensure the new OOB lib gets nugetized, or should that happen automatically?

@ghost
Copy link

ghost commented Sep 12, 2023

Hi @mgravell. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context.

@eerhardt
Copy link
Member

eerhardt commented Sep 12, 2023

@wtgodbe is there anything magic we need to do to ensure the new OOB lib gets nugetized, or should that happen automatically?

It should happen automatically because of these two lines:

You can see the new package at https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet8/NuGet/Microsoft.AspNetCore.OutputCaching.StackExchangeRedis/overview

@ghost
Copy link

ghost commented Sep 12, 2023

Hi @eerhardt. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants