Skip to content

refactor the entire redis cache module#68819

Open
Sxderp wants to merge 1 commit intosaltstack:masterfrom
Sxderp:refactor-redis-cache
Open

refactor the entire redis cache module#68819
Sxderp wants to merge 1 commit intosaltstack:masterfrom
Sxderp:refactor-redis-cache

Conversation

@Sxderp
Copy link
Copy Markdown
Contributor

@Sxderp Sxderp commented Mar 16, 2026

The old code used a complex mechanism for creating the tree hierarchy of the salt cache. The newer mechanism ustilizes a Redis sorted set as an index in which we can find subbanks by using a simple range scan.

Additionally, individual keys have been replaced with singular hash maps for each bank. This reduces the amount of bookkeeping required.

What does this PR do?

Simplifies how the redis cache works. There is no longer any need to recursively build the tree structure. A sorted set is used to organize the banks and can be queried using a range command to find the appropriate sub-banks. No benchmarks have been performed but I believe it is more efficient in the flush function and at least on pair with the list_ function due to the reduction in bookkeeping.

This change is a change in functionality and it also changes some of the config options and therefore I'm targeting master rather than any current version. There are other PRs that try to fix the current implementation #67814. I think a clean start is the better option.

I wasn't sure the best way to create tests. I ended up mocking out a Redis server that implements the functions that the cache uses. It's not the best option but it works. I hope there's a way to run an actual redis instance during tests so real results can be checked at a later time.

What issues does this PR fix or reference?

A number of issues can be closed as a result of this PR.
#54734
#60899
#66193
#67250

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

No

@Sxderp Sxderp requested a review from a team as a code owner March 16, 2026 19:27
@Sxderp Sxderp force-pushed the refactor-redis-cache branch from 883a75c to a805bd0 Compare March 16, 2026 19:30
@Sxderp Sxderp force-pushed the refactor-redis-cache branch from a805bd0 to 3278952 Compare March 16, 2026 21:50
The old code used a complex mechanism for creating the tree hierarchy of
the salt cache. The newer mechanism ustilizes a Redis sorted set as an
index in which we can find subbanks by using a simple range scan.

Additionally, individual keys have been replaced with singular hash maps
for each bank. This reduces the amount of bookkeeping required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant