Skip to content
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

Fix EnableCache to not append a dash if you pass in no args #412

Open
mccow002 opened this issue Nov 8, 2024 · 3 comments
Open

Fix EnableCache to not append a dash if you pass in no args #412

mccow002 opened this issue Nov 8, 2024 · 3 comments

Comments

@mccow002
Copy link

mccow002 commented Nov 8, 2024

When calling Query.EnableCache in a specification, it seems to expect more than one parameter. If you only pass in a single parameter, then a dash get appended to the key.

So Query.EnableCache("app:settings:123") results in a key of "app:settings:123-"

We manage our cache keys in a separate file so we can ensure consistency when both setting them and removing them. We don't rely on the Specification object to build the cache key for us because we want to manage that ourselves.

The issue is in the SpecificationBuildExtensions method, in the EnableCache method. Just change this line:

specificationBuilder.Specification.CacheKey = $"{specificationName}-{string.Join("-", args)}";

to something like

specificationBuilder.Specification.CacheKey = $"{string.Join("-", [specificationName, ..args])}";

This way a single parameter won't result in a trailing dash.

@fiseni
Copy link
Collaborator

fiseni commented Nov 9, 2024

Hey @mccow002,

This is quite old code, and it needs some attention. We'll fix it in the next version.
We might add an overload that accepts a single parameter. The params will allocate a new array instance which is waste in that scenario.

@mccow002
Copy link
Author

Any idea on when the next version is coming out?

@fiseni
Copy link
Collaborator

fiseni commented Nov 10, 2024

We just created the plan for version 9 #427
So, perhaps in a month or two.

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

No branches or pull requests

2 participants