-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Summary
Dependency keys are escaped when stored but never unescaped when read back, causing dependencies to be returned with escaped characters instead of the original values.
Root Cause
In RedisCachingBackend.cs, the GetShortKeyFromUserKey method escapes special characters:
return new ShortKey( userKey.Replace( "{", "%7B" ).Replace( "}", "%7D" ).Replace( ":", "%3A" ) );However, there is no corresponding GetUserKeyFromShortKey method to unescape these characters when reading dependencies back from Redis.
Symptoms
When a cache item has dependencies containing {, }, or : characters:
- The dependencies are stored correctly with escaped values
- When reading the item back, the dependencies array contains the escaped values (
%7B,%7D,%3A) instead of the original characters ({,},:)
Suggested Fix
Add a GetUserKeyFromShortKey method to unescape the keys:
private static string GetUserKeyFromShortKey( ShortKey shortKey )
{
return shortKey.Key
.Replace( "%7B", "{" )
.Replace( "%7D", "}" )
.Replace( "%3A", ":" );
}And call it when converting forward dependencies back to user keys in GetItemAsyncCore or similar methods.
Affected Code
PostSharp.Patterns.Caching.Backends.Redis/RedisCachingBackend.csPostSharp.Patterns.Caching.Backends.Redis/DependenciesRedisCachingBackend.cs
Filed by Claude
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels