-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCacheKeyFormatter.cs
More file actions
24 lines (21 loc) · 870 Bytes
/
Copy pathCacheKeyFormatter.cs
File metadata and controls
24 lines (21 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using TalentManagementAPI.WebApi.Caching.Options;
namespace TalentManagementAPI.WebApi.Caching.Services
{
internal static class CacheKeyFormatter
{
public static string BuildCacheKey(CachingOptions options, string key)
{
var sanitized = string.IsNullOrWhiteSpace(key) ? string.Empty : key.Trim();
return string.IsNullOrEmpty(sanitized)
? options.KeyPrefix
: string.Concat(options.KeyPrefix, ":", sanitized);
}
public static string BuildPrefixKey(CachingOptions options, string prefix)
{
var sanitized = string.IsNullOrWhiteSpace(prefix) ? string.Empty : prefix.TrimEnd(':');
return string.IsNullOrEmpty(sanitized)
? options.KeyPrefix
: string.Concat(options.KeyPrefix, ":", sanitized);
}
}
}