Comments (1)
Hi @rmandvikar , and thanks for using FusionCache!
I'm not sure I'm following you here: the things you described are not specific for how to work with FusionCache, but how to call async methods in .net itself.
Normally the CancellationToken
s are "chained", meaning that one present as a param in a method should be passed to a sub method call inside of it (if it does support it).
For example in a controller action you can have a CancellationToken
as a param, and use that when calling the database inside of the action.
Having said that, when you have a method that accept a lambda (like the factory in a GetOrSet
call), the lambda should be designed such that it can accept a CancellationToken
itself, for 2 main reasons:
- it is the signature of the lambda itself, because the signature is for a method that accepts a
CancellationToken
so it should be there as a param - by being a param of the lambda you can avoid some capturing
In your 2 examples I can see 2 separate differences:
- in the first one the lambda is specified as
async
, and inside it does anawait
, while in the second one the lambda is not marked asasync
and it does notawait
, so in the second one theTask<T>
returned byvalueProvider.GetValueAsync<T>(...)
will be returned directly. The difference in this case is mostly related to how exceptions that can be thrown will be handled by the runtime - in the first one you are using the
CancellationToken
provided to the lambda, whereas in the second one you are directly using the outer one, therefore capturing it in a closure
But again, these are not related to FusionCache itself: the same things can be said about the controller/action example I've made earlier, so I don't think I should add them to the documentation.
Closing this for now, but let me know what you think and if I've missed something I'll gladly reopen it.
from fusioncache.
Related Issues (20)
- [FEATURE] Add a method for list all caches in IFusionCacheProvider (Ex: for dispose purposes) HOT 4
- Possibility of creation of a count variable in distributed cache HOT 2
- [FEATURE] Post factory executed event with possibility to change the cache settings before it be inserted in cache HOT 3
- Syncing different cloud instances HOT 5
- [BUG] Value is stored for longer than FailSafeMaxDuration HOT 7
- [BUG] AllowBackgroundDistributedCacheOperations serialization and cache operations seem to be happening in the foreground HOT 3
- best way to store FusionCacheEntryOptions in iConfiguration HOT 3
- Nullable `Size` option HOT 3
- [BUG] Deadlock caused by cancellation of eager refresh HOT 8
- [BUG] Slow Performance of FusionCache compared to Microsoft.Extensions.Caching.Memory.MemoryCache HOT 4
- [BUG] FailSafe max duration is somehow ignored HOT 7
- [FEATURE] Optimise dependencies by adding TFM HOT 9
- 💡 Add this project to awesome-italia-opensource HOT 2
- [BUG] Possible bug. FusionCache + EntityFramework (latest) on ASP NET Core 8 (.NET 8) HOT 16
- [FEATURE] 🔺 Add .NET Aspire support HOT 1
- [FEATURE] 🔑 Add DI Keyed Services support HOT 18
- [FEATURE] Fall back Defaults for adaptive caching HOT 4
- [FEATURE] How about add compress support for large entries in distributed cache ? HOT 3
- [FEATURE] Utilize Microsoft.IO.RecyclableMemoryStream in flavor of creating new MemoryStream instances when serializing HOT 12
- [FEATURE] ⚡ Add `PreferSyncSerialization` option HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fusioncache.