Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added SitecoreFieldIEnumerableMapper fields to a related cache

  • Loading branch information...
commit 028cdf0bb3fc76561b63d6b73f19b3e1bdb6ef87 1 parent 40b4647
@gravypower gravypower authored
View
12 Source/Glass.Mapper.Sc/Caching/PublishEndCacheUpdate.cs
@@ -62,7 +62,7 @@ private void CacheWorker(Database database)
var entries = HistoryManager.GetHistory(database, startTime, endTime);
if (entries.Count > 0)
{
- var templateList = new List<string>();
+ var relatedKeyList = new List<string>();
var cache = Context.Default.ObjectCacheConfiguration.ObjectCache;
foreach (var entry in entries)
@@ -82,15 +82,19 @@ private void CacheWorker(Database database)
if (item == null) continue;
var templaetId = item.TemplateID.ToString();
- if (templateList.All(x => x != templaetId))
- templateList.Add(templaetId);
+ if (relatedKeyList.All(x => x != templaetId))
+ relatedKeyList.Add(templaetId);
+
+ relatedKeyList.Add(item.ID + "SitecoreFieldIEnumerableMapper");
}
//clear the related caches after the index has finished updating
- foreach (var teamplet in templateList)
+ foreach (var teamplet in relatedKeyList)
{
cache.ClearRelatedCache(teamplet);
}
+
+
}
//update the last update time
View
2  Source/Glass.Mapper.Sc/DataMappers/SitecoreFieldIEnumerableMapper.cs
@@ -48,7 +48,7 @@ public override object GetFieldValue(string fieldValue, SitecoreFieldConfigurati
if (context != null && context.Service.GlassContext.ObjectCacheConfiguration != null)
{
var cacheKey = config.FieldName + context.Item.ID.Guid.ToString();
- context.Service.GlassContext.ObjectCacheConfiguration.ObjectCache.AddToRelatedCache(cacheKey, "", list);
+ context.Service.GlassContext.ObjectCacheConfiguration.ObjectCache.AddToRelatedCache(cacheKey, context.Item.ID + "SitecoreFieldIEnumerableMapper", list);
}
return list;
Please sign in to comment.
Something went wrong with that request. Please try again.