Skip to content
Discussion options

You must be logged in to vote

Anyway, as an MRE you can try this:

var fc = new FusionCache(new FusionCacheOptions());

var v1 = fc.GetOrSet<int>(
	"foo",
	_ => 123,
	options => options
		.SetDuration(TimeSpan.FromSeconds(3))
		.SetFailSafe(true, TimeSpan.FromMinutes(2), TimeSpan.FromSeconds(5))
);

Console.WriteLine($"v1: {v1}");

await Task.Delay(TimeSpan.FromSeconds(4));

var v2 = fc.GetOrSet<int>(
	"foo",
	_ => throw new Exception("BOOM!"),
	options => options
		.SetDuration(TimeSpan.FromSeconds(3))
		.SetFailSafe(true, TimeSpan.FromMinutes(2), TimeSpan.FromSeconds(5))
);

Console.WriteLine($"v2: {v2}");

For which you can see that the output is:

v1: 123
v2: 123

As soon as you disable fail-safe on the 2nd call, you…

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@bendursley
Comment options

@bendursley
Comment options

Answer selected by bendursley
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jodydonetti
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants