-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyBuilder.cs
More file actions
31 lines (25 loc) · 796 Bytes
/
KeyBuilder.cs
File metadata and controls
31 lines (25 loc) · 796 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
25
26
27
28
29
30
31
using System.Text;
internal class KeyBuilder
{
private readonly string _keyPrefix;
private static readonly StringBuilder _stringBuilder = new();
private static readonly string Seperator = ":";
internal KeyBuilder(RedisConnectionConfiguration configuration)
{
_keyPrefix = configuration.KeyPrefix ?? string.Empty;
}
internal string Build(string key)
{
if (string.IsNullOrEmpty(_keyPrefix) || string.IsNullOrWhiteSpace(_keyPrefix))
{
return key;
}
if (_stringBuilder.Length > 0) {
_stringBuilder.Clear();
}
_stringBuilder.Append(_keyPrefix);
_stringBuilder.Append(Seperator);
_stringBuilder.Append(key);
return _stringBuilder.ToString();
}
}