fix: configuration optimization
This commit is contained in:
@@ -34,11 +34,11 @@ namespace Disco.Data.Configuration
|
|||||||
|
|
||||||
private void SetValue<T>(string Key, T Value)
|
private void SetValue<T>(string Key, T Value)
|
||||||
{
|
{
|
||||||
ConfigurationCache.SetValue(Database, this.Scope, Key, Value);
|
ConfigurationCache.Helpers<T>.SetValue(Database, this.Scope, Key, Value);
|
||||||
}
|
}
|
||||||
private T GetValue<T>(string Key, T Default)
|
private T GetValue<T>(string Key, T Default)
|
||||||
{
|
{
|
||||||
return ConfigurationCache.GetValue(Database, this.Scope, Key, Default);
|
return ConfigurationCache.Helpers<T>.GetValue(Database, this.Scope, Key, Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Set<T>(T Value, [CallerMemberName] string Key = null)
|
protected void Set<T>(T Value, [CallerMemberName] string Key = null)
|
||||||
|
|||||||
@@ -202,7 +202,11 @@ namespace Disco.Data.Configuration
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Cache Getters/Setters
|
#region Cache Getters/Setters
|
||||||
internal static T GetValue<T>(DiscoDataContext Database, string Scope, string Key, T Default)
|
internal static class Helpers<T>
|
||||||
|
{
|
||||||
|
private static readonly IEqualityComparer<T> comparer = EqualityComparer<T>.Default;
|
||||||
|
|
||||||
|
internal static T GetValue(DiscoDataContext Database, string Scope, string Key, T Default)
|
||||||
{
|
{
|
||||||
var item = CacheGetItem(Database, Scope, Key);
|
var item = CacheGetItem(Database, Scope, Key);
|
||||||
|
|
||||||
@@ -254,12 +258,12 @@ namespace Disco.Data.Configuration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal static void SetValue<T>(DiscoDataContext Database, string Scope, string Key, T Value)
|
internal static void SetValue(DiscoDataContext Database, string Scope, string Key, T Value)
|
||||||
{
|
{
|
||||||
Type valueType = typeof(T);
|
Type valueType = typeof(T);
|
||||||
string stringValue;
|
string stringValue;
|
||||||
|
|
||||||
if (Value == null)
|
if (comparer.Equals(Value, default(T)))
|
||||||
{
|
{
|
||||||
stringValue = null;
|
stringValue = null;
|
||||||
}
|
}
|
||||||
@@ -285,6 +289,8 @@ namespace Disco.Data.Configuration
|
|||||||
|
|
||||||
CacheSetItem(Database, Scope, Key, stringValue, Value);
|
CacheSetItem(Database, Scope, Key, stringValue, Value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Cache Helpers
|
#region Cache Helpers
|
||||||
|
|||||||
Reference in New Issue
Block a user