You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using JetBrains.Annotations;
|
|
using Volo.Abp.MultiTenancy;
|
|
using Volo.Abp.Text.Formatting;
|
|
|
|
namespace NPin.Framework.SettingManagement.Domain.Caching;
|
|
|
|
/// <summary>
|
|
/// 设置缓存项
|
|
/// 忽略多租户
|
|
/// </summary>
|
|
[Serializable]
|
|
[IgnoreMultiTenancy]
|
|
public class SettingCacheItem
|
|
{
|
|
/// <summary>
|
|
/// 缓存Key格式化参数
|
|
/// pn: providerName
|
|
/// pk: providerKey
|
|
/// n: name
|
|
/// </summary>
|
|
private const string CacheKeyFormat = "pn:{0},pk:{1},n:{2}";
|
|
|
|
/// <summary>
|
|
/// 值
|
|
/// </summary>
|
|
public string? Value { get; set; }
|
|
|
|
public SettingCacheItem()
|
|
{
|
|
}
|
|
|
|
public SettingCacheItem(string? value)
|
|
{
|
|
Value = value;
|
|
}
|
|
|
|
public static string CalculateCacheKey(string name, string providerName, string providerKey)
|
|
{
|
|
return string.Format(CacheKeyFormat, providerName, providerKey, name);
|
|
}
|
|
|
|
public static string? GetSettingNameFormCacheKeyOrNull(string cacheKey)
|
|
{
|
|
var result = FormattedStringValueExtracter.Extract(cacheKey, CacheKeyFormat, true);
|
|
return result.IsMatch ? result.Matches.Last().Value : null;
|
|
}
|
|
} |