Skip to content

Conversation

@fvoronin
Copy link
Contributor

@fvoronin fvoronin commented Dec 7, 2021

Summary of the changes

Checking Redis version and then calling the right API.

A couple of questions:

  • Is it necessary to log the switch to the old API?
  • What to do with integration tests? They are currently disabled.

Fixes #38715

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Dec 7, 2021
private const string SlidingExpirationKey = "sldexp";
private const string DataKey = "data";
private const long NotPresent = -1;
private readonly Version ServerVersionWithExtendedSetCommand = new Version(4, 0, 0);
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
private readonly Version ServerVersionWithExtendedSetCommand = new Version(4, 0, 0);
private static readonly Version ServerVersionWithExtendedSetCommand = new Version(4, 0, 0);

Maybe?

// ARGV[4] = data - byte[]
// this order should not change LUA script depends on it
private const string SetScript = (@"
private const string RegularSetScript = (@"
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
private const string RegularSetScript = (@"
private const string LatestSetScript = (@"

// ARGV[4] = data - byte[]
// this order should not change LUA script depends on it
private const string SetScript = (@"
private const string LatestSetScript = (@"
Copy link
Member

@adityamandaleeka adityamandaleeka Dec 8, 2021

Choose a reason for hiding this comment

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

Nit: Consider names other than "Latest..." and "Deprecated...". Maybe "SetScript_HsetBased" and "SetScript_HmsetBased" or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing good comes to mind :(
Imho, nearby comment, explaining why two types of SetScript are used, helps a lot.

Copy link
Member

Choose a reason for hiding this comment

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

FWIW I'd name this aligned with the property, e.g. SetScriptPreExtendedSetCommand - verbose but super clear.

Copy link
Member

@adityamandaleeka adityamandaleeka left a comment

Choose a reason for hiding this comment

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

Thanks @fvoronin, this looks good to me aside from a couple of minor comments I left.

@adityamandaleeka adityamandaleeka merged commit aa615ef into dotnet:main Dec 9, 2021
@ghost ghost added this to the 7.0-preview1 milestone Dec 9, 2021
@adityamandaleeka
Copy link
Member

Thanks @fvoronin!

@wtgodbe
Copy link
Member

wtgodbe commented Dec 9, 2021

/backport to release/6.0

@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2021

Started backporting to release/6.0: https://github.com/dotnet/aspnetcore/actions/runs/1561207568

@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2021

@wtgodbe backporting to release/6.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Fix RedisCache update that breaks usage against older redis servers (#38715)
Applying: Suggested changes (#38715)
Applying: Suggested changes (#38715)
Applying: Explanation of why two kinds of SetScript are used
error: sha1 information is lacking or useless (src/Caching/StackExchangeRedis/src/RedisCache.cs).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0004 Explanation of why two kinds of SetScript are used
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

// ARGV[4] = data - byte[]
// this order should not change LUA script depends on it
private const string SetScript = (@"
private const string SetScriptPerExtendedSetCommand = (@"
Copy link
Member

Choose a reason for hiding this comment

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

@NickCraver @adityamandaleeka Was this supposed to be SetScriptPreExtendedSetCommand? And was this meant to apply to what's currently called DeprecatedSetScript?

Copy link
Member

Choose a reason for hiding this comment

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

@halter73 You're right, that's how I interpreted @NickCraver's comment too. I saw that it was renamed but didn't catch that it was applied to the newer one (in which case I guess "per" kinda makes sense 😄).

Copy link
Member

Choose a reason for hiding this comment

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

@halter73 yep, that's what I was pitching there :)

Copy link
Member

Choose a reason for hiding this comment

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

I'll send a quick PR to rename them to SetScript and SetScriptPreExtendedSetCommand.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Thanks again for noticing that @halter73

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fvoronin fvoronin deleted the cache-update-for-older-redis-servers-38715 branch May 4, 2022 17:22
@amcasey amcasey added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RedisCache update in .NET 6 breaks usage against older redis servers

9 participants