NuCache+Scope - tests
This commit is contained in:
@@ -855,6 +855,12 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
}
|
||||
}
|
||||
|
||||
public Snapshot LiveSnapshot => new Snapshot(this, _liveGen
|
||||
#if DEBUG
|
||||
, _logger
|
||||
#endif
|
||||
);
|
||||
|
||||
public Task CollectAsync()
|
||||
{
|
||||
lock (_rlocko)
|
||||
@@ -996,8 +1002,6 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
set => _store._collectAuto = value;
|
||||
}
|
||||
|
||||
public Snapshot LiveSnapshot => new Snapshot(_store, _store._liveGen);
|
||||
|
||||
public Tuple<long, ContentNode>[] GetValues(int id)
|
||||
{
|
||||
_store._contentNodes.TryGetValue(id, out LinkedNode<ContentNode> link); // else null
|
||||
@@ -1069,10 +1073,19 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
#endif
|
||||
}
|
||||
|
||||
internal Snapshot(ContentStore store, long gen)
|
||||
internal Snapshot(ContentStore store, long gen
|
||||
#if DEBUG
|
||||
, ILogger logger
|
||||
#endif
|
||||
)
|
||||
{
|
||||
_store = store;
|
||||
_gen = gen;
|
||||
|
||||
#if DEBUG
|
||||
_logger = logger;
|
||||
_logger.Debug<Snapshot>("Creating live.");
|
||||
#endif
|
||||
}
|
||||
|
||||
public ContentNode Get(int id)
|
||||
@@ -1146,7 +1159,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
if (_gen < 0) return;
|
||||
#if DEBUG
|
||||
_logger.Debug<Snapshot>("Dispose snapshot (" + _genRef.GenRefRef.Count + ").");
|
||||
_logger.Debug<Snapshot>("Dispose snapshot (" + (_genRef?.GenRefRef.Count.ToString() ?? "live") + ").");
|
||||
#endif
|
||||
_gen = -1;
|
||||
if (_genRef != null)
|
||||
|
||||
@@ -939,10 +939,28 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
ICacheProvider snapshotCache;
|
||||
lock (_storesLock)
|
||||
{
|
||||
contentSnap = _contentStore.CreateSnapshot();
|
||||
mediaSnap = _mediaStore.CreateSnapshot();
|
||||
domainSnap = _domainStore.CreateSnapshot();
|
||||
snapshotCache = _snapshotCache;
|
||||
var scopeContext = _scopeProvider.Context;
|
||||
|
||||
if (scopeContext == null)
|
||||
{
|
||||
contentSnap = _contentStore.CreateSnapshot();
|
||||
mediaSnap = _mediaStore.CreateSnapshot();
|
||||
domainSnap = _domainStore.CreateSnapshot();
|
||||
snapshotCache = _snapshotCache;
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME
|
||||
contentSnap = _contentStore.LiveSnapshot;
|
||||
mediaSnap = _mediaStore.LiveSnapshot;
|
||||
domainSnap = _domainStore.Test.LiveSnapshot;
|
||||
snapshotCache = _snapshotCache;
|
||||
|
||||
scopeContext.Enlist("Umbraco.Web.PublishedCache.NuCache.FacadeService.FooDang", () => this, (completed, svc) =>
|
||||
{
|
||||
((Facade) svc.CurrentFacade).Resync();
|
||||
});
|
||||
}
|
||||
|
||||
// create a new snapshot cache if snapshots are different gens
|
||||
if (contentSnap.Gen != _contentGen || mediaSnap.Gen != _mediaGen || domainSnap.Gen != _domainGen || _snapshotCache == null)
|
||||
@@ -954,9 +972,11 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME the facade cache is a problem here when it's the request cache?!
|
||||
var facadeCache = _options.FacadeCacheIsApplicationRequestCache
|
||||
? Current.ApplicationCache.RequestCache
|
||||
: new StaticCacheProvider(); // assuming that's OK for tests, etc
|
||||
|
||||
var memberTypeCache = new PublishedContentTypeCache(null, null, _serviceContext.MemberTypeService, _logger);
|
||||
|
||||
var domainCache = new DomainCache(domainSnap);
|
||||
|
||||
Reference in New Issue
Block a user