Move cache keys to Constants
This commit is contained in:
@@ -5,5 +5,9 @@
|
||||
public const string PropertyEditorAlias = "Imulus.Archetype";
|
||||
|
||||
public const string PreValueAlias = "archetypeConfig";
|
||||
|
||||
public const string CacheKey_DataTypeByGuid = "";
|
||||
|
||||
public const string CacheKey_PreValueFromDataTypeId = "Archetype_GetArchetypePreValueFromDataTypeId_";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,11 @@ namespace Archetype.Umbraco.Events
|
||||
|
||||
void ExpirePreValueCache(IDataTypeService sender, global::Umbraco.Core.Events.SaveEventArgs<IDataTypeDefinition> e)
|
||||
{
|
||||
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem("Archetype_GetArchetypePreValueFromDataTypeId_" + e.SavedEntities.First().Id);
|
||||
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem("Archetype_GetArchetypePreValueFromDataTypeId_GetPropertyEditorAlias_"+ e.SavedEntities.First().Id);
|
||||
foreach (var dataType in e.SavedEntities)
|
||||
{
|
||||
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(Constants.CacheKey_PreValueFromDataTypeId + dataType.Id);
|
||||
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(Constants.CacheKey_DataTypeByGuid + dataType.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Archetype.Umbraco.PropertyConverters
|
||||
private ArchetypePreValue GetArchetypePreValueFromDataTypeId(int dataTypeId, IDictionary<Guid, IDataTypeDefinition> dataTypeCache)
|
||||
{
|
||||
return ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem(
|
||||
"Archetype_GetArchetypePreValueFromDataTypeId_" + dataTypeId,
|
||||
Constants.CacheKey_PreValueFromDataTypeId + dataTypeId,
|
||||
() =>
|
||||
{
|
||||
var preValues = Services.DataTypeService.GetPreValuesCollectionByDataTypeId(dataTypeId);
|
||||
@@ -122,7 +122,7 @@ namespace Archetype.Umbraco.PropertyConverters
|
||||
private IDataTypeDefinition GetDataTypeByGuid(Guid guid)
|
||||
{
|
||||
return (IDataTypeDefinition) ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem(
|
||||
"Archetype_GetDataTypeDefinitionById_" + guid,
|
||||
Constants.CacheKey_DataTypeByGuid + guid,
|
||||
() => Services.DataTypeService.GetDataTypeDefinitionById(guid));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user