Skip to content

Commit

Permalink
362 Remove ToLower in CacheKey generation
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitryk-kontent-ai committed Feb 23, 2023
1 parent 2f41941 commit 4e1bc08
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
21 changes: 19 additions & 2 deletions Kontent.Ai.Delivery.Caching.Tests/CacheHelpersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public void GetItemKey_WithDifferentValues_AreUnique()
CacheHelpers.GetItemKey<object>("codename", new []{new DepthParameter(1)}),
CacheHelpers.GetItemKey<object>("codename", new [] {new DepthParameter(2) }),
CacheHelpers.GetItemKey<object>("codename", new []{new SystemTypeEqualsFilter("article") }),
CacheHelpers.GetItemKey<Article>("codename", new []{new SystemTypeEqualsFilter("article") })
CacheHelpers.GetItemKey<Article>("codename", new []{new SystemTypeEqualsFilter("article") }),
CacheHelpers.GetItemKey<SomeClass>("codename", Enumerable.Empty<IQueryParameter>()),
CacheHelpers.GetItemKey<someclass>("codename", Enumerable.Empty<IQueryParameter>()),
CacheHelpers.GetItemKey<AnotherNamespace.SomeClass>("codename", Enumerable.Empty<IQueryParameter>()),
CacheHelpers.GetItemKey<AnotherNamespace.someclass>("codename", Enumerable.Empty<IQueryParameter>()),
};

keys.Distinct().Count().Should().Be(keys.Length);
Expand All @@ -37,7 +41,11 @@ public void GetItemsKey_WithDifferentValues_AreUnique()
CacheHelpers.GetItemsKey<object>(new []{new DepthParameter(1)}),
CacheHelpers.GetItemsKey<object>(new [] {new DepthParameter(2) }),
CacheHelpers.GetItemsKey<object>(new []{new SystemTypeEqualsFilter("article") }) ,
CacheHelpers.GetItemsKey<Article>(new []{new SystemTypeEqualsFilter("article") })
CacheHelpers.GetItemsKey<Article>(new []{new SystemTypeEqualsFilter("article") }),
CacheHelpers.GetItemsKey<SomeClass>(Enumerable.Empty<IQueryParameter>()),
CacheHelpers.GetItemsKey<someclass>(Enumerable.Empty<IQueryParameter>()),
CacheHelpers.GetItemsKey<AnotherNamespace.SomeClass>(Enumerable.Empty<IQueryParameter>()),
CacheHelpers.GetItemsKey<AnotherNamespace.someclass>(Enumerable.Empty<IQueryParameter>()),
};

keys.Distinct().Count().Should().Be(keys.Length);
Expand Down Expand Up @@ -110,5 +118,14 @@ public void GetContentElementKey_WithDifferentValues_AreUnique()

#endregion
}

internal class SomeClass { }
internal class someclass { }
}

namespace Kontent.Ai.Delivery.Caching.Tests.AnotherNamespace
{
internal class SomeClass { }
internal class someclass { }
}

4 changes: 2 additions & 2 deletions Kontent.Ai.Delivery.Caching/CacheHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static class CacheHelpers
/// <returns>Dependency key</returns>
public static string GetItemKey<T>(string codename, IEnumerable<IQueryParameter> parameters)
{
return StringHelpers.Join(new[] { typeof(T).FullName.ToLower(), CONTENT_ITEM_TYPED_IDENTIFIER, codename }.Concat(parameters?.Select(x => x.GetQueryStringParameter()) ?? Enumerable.Empty<string>()));
return StringHelpers.Join(new[] { typeof(T).FullName, CONTENT_ITEM_TYPED_IDENTIFIER, codename }.Concat(parameters?.Select(x => x.GetQueryStringParameter()) ?? Enumerable.Empty<string>()));
}

/// <summary>
Expand All @@ -57,7 +57,7 @@ public static string GetItemKey<T>(string codename, IEnumerable<IQueryParameter>
/// <returns>Dependency keys</returns>
public static string GetItemsKey<T>(IEnumerable<IQueryParameter> parameters)
{
return StringHelpers.Join(new[] { typeof(T).FullName.ToLower(), CONTENT_ITEM_LISTING_TYPED_IDENTIFIER }.Concat(parameters?.Select(x => x.GetQueryStringParameter()) ?? Enumerable.Empty<string>()));
return StringHelpers.Join(new[] { typeof(T).FullName, CONTENT_ITEM_LISTING_TYPED_IDENTIFIER }.Concat(parameters?.Select(x => x.GetQueryStringParameter()) ?? Enumerable.Empty<string>()));
}

/// <summary>
Expand Down

0 comments on commit 4e1bc08

Please sign in to comment.