Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in Wiki: Why does the Cancellation Tokens example use two CancellationTokenSource? #185

Open
schittli opened this issue Feb 23, 2023 · 0 comments
Labels

Comments

@schittli
Copy link

Hello,
thank you for sharing your great work!

Describe the bug

'bug' is the best matching issue type because the doc in Wiki is very useful, but it has still one open question:

Here: https://github.com/alastairtree/LazyCache/wiki/API-documentation-(v-2.x)
in Chapter: Method 2 - Cancellation Tokens (could also be used to dispose a range of items)

The doc explains how to add two items to the cache using a Cancellation Token.
But why does the example calculates options2 to add the 2nd item to the cache?
Why is it not possible to just re-use options1 like this:?

var expireToken1 = new CancellationChangeToken(sharedExpiryTokenSource.Token);
var options1 = new MemoryCacheEntryOptions()
                   .AddExpirationToken(expireToken)
var product1 = cache.GetOrAdd($"Products-1", () => dbContext.Products.GetAsync(1), options1);
var product2 = cache.GetOrAdd($"Products-2", () => dbContext.Products.GetAsync(2), options1);

Thanks a lot, kind regards,
Thomas

@schittli schittli added the bug label Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant