// ====================================================================== Transaction callback internal static void RemoveFromCache(NodeDataParticipant participant) // orig name: OnNodeDataCommit { // Do not fire any events if the node is new: // it cannot effect any other content if (participant.IsNewNode) { return; } var data = participant.Data; // Remove items from Cache by the OriginalPath, before getting an update // of a - occassionally differring - path from the database if (data.PathChanged) { PathDependency.FireChanged(data.OriginalPath); } if (data.ContentListTypeId != 0 && data.ContentListId == 0) { // If list, invalidate full subtree PathDependency.FireChanged(data.Path); } else { // If not a list, invalidate item NodeIdDependency.FireChanged(data.Id); } }
private void Changed(object sender, EventArgs <int> e) { if (NodeIdDependency.IsChanged(e.Data, _nodeId)) { OnChanged(null); } }
protected override void Dispose(bool disposing) { if (disposing) { NodeIdDependency.Unsubscribe(Changed); } }
/// <summary> /// Finalizes a chunk saving process: sets the stream size and length for the binary. /// </summary> /// <param name="contentId">Id of the content</param> /// <param name="token">The token received from the StartChunk method that needs to be called before the chunk saving operation starts.</param> /// <param name="fullStreamSize">Full size of the binary stream</param> /// <param name="fieldName">Name of the field. Default: Binary</param> /// <param name="binaryMetadata">Additional metadata for the binary row: file name, extension, content type.</param> public static void CommitChunk(int contentId, string token, long fullStreamSize, string fieldName = "Binary", BinaryData binaryMetadata = null) { Node node; PropertyType pt; AssertChunk(contentId, fieldName, out node, out pt); DataProvider.Current.CommitChunk(node.VersionId, pt.Id, token, fullStreamSize, binaryMetadata == null ? null : binaryMetadata.RawData); NodeIdDependency.FireChanged(node.Id); StorageContext.L2Cache.Clear(); }
public NodeIdChangeMonitor(int nodeId) { _nodeId = nodeId; try { NodeIdDependency.Subscribe(Changed); } finally { InitializationComplete(); } }
/// <inheritdoc /> public override void Save(NodeSaveSettings settings) { AssertSettings(); if (_dynamicFieldsChanged && BinaryAsJObject != null) { // If this is a JSON settings file and the dynamic metadata changed, save the JSON binary according to the changes JsonDynamicFieldHelper.SaveToStream(BinaryAsJObject, stream => { this.Binary.SetStream(stream); base.Save(settings); _dynamicFieldsChanged = false; }); } else { base.Save(settings); } // Find all settings that inherit from this setting and remove their cached data if (RepositoryInstance.LuceneManagerIsRunning && !RepositoryEnvironment.WorkingMode.Importing) { string contextPath = null; if (this.ParentPath.StartsWith(SETTINGSCONTAINERPATH, true, System.Globalization.CultureInfo.InvariantCulture)) { contextPath = "/Root"; } else { contextPath = GetParentContextPath(this.Path); } if (contextPath == null) { using (new SystemAccount()) { var q = ContentQuery.Query(SafeQueries.InTreeAndTypeIsAndName, new QuerySettings { EnableAutofilters = FilterStatus.Disabled }, contextPath, typeof(Settings).Name, this.Name); foreach (var id in q.Identifiers) { NodeIdDependency.FireChanged(id); } } } } }
public void Cache_Builtin_NodeIdDependency_Private() { Test((builder) => { builder.UseCacheProvider(new SnMemoryCache()); }, () => { var cache = DistributedApplication.Cache; cache.Reset(); // create node1 and cache it with it own NodeIdDependency var node1 = CreateTestRoot(); var nodeId1 = node1.Id; var nodeData1 = node1.Data; var key1 = "NodeData." + node1.VersionId; var dependencies1 = new NodeIdDependency(node1.Id); cache.Insert(key1, nodeData1, dependencies1); // create node2 and cache it with it own NodeIdDependency var node2 = CreateTestRoot(); var nodeId2 = node2.Id; var nodeData2 = node2.Data; var key2 = "NodeData." + node2.VersionId; var dependencies2 = new NodeIdDependency(node2.Id); cache.Insert(key2, nodeData2, dependencies2); // pre-check: nodes are in the cache Assert.IsTrue(IsInCache(key1)); Assert.IsTrue(IsInCache(key2)); // TEST#1: remove unknown node via NodeIdDependency NodeIdDependency.FireChanged(Math.Max(nodeId1, nodeId2) + 42); Assert.IsTrue(IsInCache(key1)); Assert.IsTrue(IsInCache(key2)); // TEST#2: remove node1 wia NodeIdDependency NodeIdDependency.FireChanged(nodeId1); Assert.IsFalse(IsInCache(key1)); Assert.IsTrue(IsInCache(key2)); // add node1 again dependencies1 = new NodeIdDependency(node1.Id); cache.Insert(key1, nodeData1, dependencies1); // TEST#3: remove node1 wia NodeIdDependency NodeIdDependency.FireChanged(nodeId2); Assert.IsTrue(IsInCache(key1)); Assert.IsFalse(IsInCache(key2)); }); }
public void Cache_Builtin_NodeIdDependency_Private() { Test2((services) => { services.AddSingleton <ISnCache, SnMemoryCache>(); }, () => { Cache.Reset(); // create node1 and cache it with it own NodeIdDependency var node1 = CreateTestRoot(); var nodeId1 = node1.Id; var nodeData1 = node1.Data; var key1 = "NodeData." + node1.VersionId; var dependencies1 = new NodeIdDependency(node1.Id); Cache.Insert(key1, nodeData1, dependencies1); // create node2 and cache it with it own NodeIdDependency var node2 = CreateTestRoot(); var nodeId2 = node2.Id; var nodeData2 = node2.Data; var key2 = "NodeData." + node2.VersionId; var dependencies2 = new NodeIdDependency(node2.Id); Cache.Insert(key2, nodeData2, dependencies2); // pre-check: nodes are in the cache Assert.IsTrue(IsInCache(key1)); Assert.IsTrue(IsInCache(key2)); // TEST#1: remove unknown node via NodeIdDependency NodeIdDependency.FireChanged(Math.Max(nodeId1, nodeId2) + 42); Assert.IsTrue(IsInCache(key1)); Assert.IsTrue(IsInCache(key2)); // TEST#2: remove node1 wia NodeIdDependency NodeIdDependency.FireChanged(nodeId1); Assert.IsFalse(IsInCache(key1)); Assert.IsTrue(IsInCache(key2)); // add node1 again dependencies1 = new NodeIdDependency(node1.Id); Cache.Insert(key1, nodeData1, dependencies1); // TEST#3: remove node1 wia NodeIdDependency NodeIdDependency.FireChanged(nodeId2); Assert.IsTrue(IsInCache(key1)); Assert.IsFalse(IsInCache(key2)); }); }
public void Cache_Builtin_NodeIdDependency_Shared() { Test((builder) => { builder.UseCacheProvider(new SnMemoryCache()); }, () => { Cache.Reset(); // create node1 and cache it with a shared NodeIdDependency var node1 = CreateTestRoot(); var nodeId1 = node1.Id; var nodeData1 = node1.Data; var key1 = "NodeData." + node1.VersionId; var dependencies1 = new NodeIdDependency(nodeId1); Cache.Insert(key1, nodeData1, dependencies1); // create node2 and cache it with NodeIdDependency by node1 var node2 = CreateTestRoot(); var nodeId2 = node2.Id; var nodeData2 = node2.Data; var key2 = "NodeData." + node2.VersionId; var dependencies2 = new NodeIdDependency(nodeId1); // nodeId1 is the right value! Cache.Insert(key2, nodeData2, dependencies2); // pre-check: nodes are in the cache Assert.IsTrue(IsInCache(key1)); Assert.IsTrue(IsInCache(key2)); // TEST#1: remove unknown node wia NodeIdDependency NodeIdDependency.FireChanged(Math.Max(nodeId1, nodeId2) + 42); Assert.IsTrue(IsInCache(key1)); Assert.IsTrue(IsInCache(key2)); // TEST#2: remove nodes wia nodeId2 (not affected) NodeIdDependency.FireChanged(nodeId2); Assert.IsTrue(IsInCache(key1)); Assert.IsTrue(IsInCache(key2)); // TEST#3: remove node1 wia NodeIdDependency NodeIdDependency.FireChanged(nodeId1); Assert.IsFalse(IsInCache(key1)); Assert.IsFalse(IsInCache(key2)); }); }
private void RemoveFromCache(NodeData data) { // Remove items from Cache by the OriginalPath, before getting an update // of a - occassionally differring - path from the database if (data.PathChanged) { PathDependency.FireChanged(data.OriginalPath); } if (data.ContentListTypeId != 0 && data.ContentListId == 0) { // If list, invalidate full subtree PathDependency.FireChanged(data.Path); } else { // If not a list, invalidate item NodeIdDependency.FireChanged(data.Id); } }
internal static void RemoveBreakPermissionInheritance(Node node) { DataProvider.Current.RemoveBreakInheritance(node.Id); NodeIdDependency.FireChanged(node.Id); PathDependency.FireChanged(node.Path); }