From 949f7fed381024e83b5206a5cac9ecd8c171173e Mon Sep 17 00:00:00 2001 From: Omar <56449814+oasaleh@users.noreply.github.com> Date: Fri, 1 Nov 2024 15:57:22 -0500 Subject: [PATCH 1/2] Update AutoClone.md Rephrase the comments to make them clearer as to what's going on. --- docs/AutoClone.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/AutoClone.md b/docs/AutoClone.md index bf58b5c..c0fc85d 100644 --- a/docs/AutoClone.md +++ b/docs/AutoClone.md @@ -82,19 +82,19 @@ cache.SetupSerializer(new FusionCacheSystemTextJsonSerializer()); cache.Set("foo", new Person { Name = "John" }); -// THIS WILL GET A CLONE +// RETURNS A CLONE OF CACHED INSTANCE (ORIGINAL REMAINS UNCHANGED) var person1 = cache.GetOrDefault("foo", options => options.SetAutoClone(true)); Console.WriteLine($"person1: {person1.Name}"); Console.WriteLine(); -// THIS WILL GET A CLONE, AND CHANGE (ONLY) IT +// RETURNS A CLONE OF CACHED INSTANCE (MODIFICATIONS AFFECT ONLY THE CLONE) var person2 = cache.GetOrDefault("foo", options => options.SetAutoClone(true)); person2.Name = "Jane"; Console.WriteLine($"person1: {person1.Name}"); Console.WriteLine($"person2: {person2.Name}"); Console.WriteLine(); -// THIS WILL GET THE INSTANCE IN THE CACHE, AND CHANGE IT +// RETURNS DIRECT REFERENCE TO CACHED INSTANCE (MODIFICATIONS AFFECT THE CACHE) var person3 = cache.GetOrDefault("foo"); person3.Name = "Jim"; Console.WriteLine($"person1: {person1.Name}"); @@ -102,8 +102,8 @@ Console.WriteLine($"person2: {person2.Name}"); Console.WriteLine($"person3: {person3.Name}"); Console.WriteLine(); -// THIS WILL GET THE INSTANCE IN THE CACHE AGAIN, AND CHANGE IT -// SO, BOTH person3 AND person4 WILL HAVE THE SAME REFERENCE +// RETURNS SAME REFERENCE TO CACHED INSTANCE +// MODIFICATIONS AFFECT BOTH person3 AND person4 AS THEY SHARE THE CACHED REFERENCE var person4 = cache.GetOrDefault("foo"); person4.Name = "Joe"; From c3b148d4096bbbd58df6f4cab44f15419e4f1f39 Mon Sep 17 00:00:00 2001 From: Jody Donetti Date: Wed, 27 Nov 2024 23:47:07 +0100 Subject: [PATCH 2/2] Update AutoClone.md Slightly changed the phrasing --- docs/AutoClone.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/AutoClone.md b/docs/AutoClone.md index c0fc85d..c68cb62 100644 --- a/docs/AutoClone.md +++ b/docs/AutoClone.md @@ -82,19 +82,19 @@ cache.SetupSerializer(new FusionCacheSystemTextJsonSerializer()); cache.Set("foo", new Person { Name = "John" }); -// RETURNS A CLONE OF CACHED INSTANCE (ORIGINAL REMAINS UNCHANGED) +// RETURNS A CLONE OF THE CACHED INSTANCE var person1 = cache.GetOrDefault("foo", options => options.SetAutoClone(true)); Console.WriteLine($"person1: {person1.Name}"); Console.WriteLine(); -// RETURNS A CLONE OF CACHED INSTANCE (MODIFICATIONS AFFECT ONLY THE CLONE) +// RETURNS A CLONE OF THE CACHED INSTANCE: CHANGES APPLIED ONLY THE CLONE, CACHED INSTANCE REMAINS UNCHANGED var person2 = cache.GetOrDefault("foo", options => options.SetAutoClone(true)); person2.Name = "Jane"; Console.WriteLine($"person1: {person1.Name}"); Console.WriteLine($"person2: {person2.Name}"); Console.WriteLine(); -// RETURNS DIRECT REFERENCE TO CACHED INSTANCE (MODIFICATIONS AFFECT THE CACHE) +// RETURNS DIRECT REFERENCE TO THE CACHED INSTANCE: CHANGES APPLIED TO THE CACHED INSTANCE ITSELF var person3 = cache.GetOrDefault("foo"); person3.Name = "Jim"; Console.WriteLine($"person1: {person1.Name}"); @@ -102,8 +102,8 @@ Console.WriteLine($"person2: {person2.Name}"); Console.WriteLine($"person3: {person3.Name}"); Console.WriteLine(); -// RETURNS SAME REFERENCE TO CACHED INSTANCE -// MODIFICATIONS AFFECT BOTH person3 AND person4 AS THEY SHARE THE CACHED REFERENCE +// RETURNS DIRECT REFERENCE TO THE CACHED INSTANCE: THE INSTANCE IS THE SAME AS BEFORE +// CHANGES APPLIED TO BOTH person3 AND person4 AS THEY POINT TO THE SAME CACHED INSTANCE var person4 = cache.GetOrDefault("foo"); person4.Name = "Joe";