8000 Fix EnableCache to not append a dash if you pass in no args · Issue #412 · ardalis/Specification · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Fix EnableCache to not append a dash if you pass in no args #412
Closed
@mccow002

Description

@mccow002

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0