Comments (3)
Hi @hvgNET and thanks for considering FusionCache.
Sorry for the delay in answering but covid finally got me.
In general your idea seems the right one to me:
- load all 10.000.000 items from the db in one go
- save them all in the cache individually with a
Set
call for each of them (with a reasonable cache duration)
Then, when you need one of them during the lifetime of your application, call GetOrSet({id}, _ => GetValue(id))
so that if the value is still in the cache you'll get it back immediately and, if not in the cache anymore, it will be loaded from the db and saved in the cache.
There's this passage that I don't understand though:
But that just seems... a bit hacky to me as i neither want to get nor set the value, i just want to set the factory up
Why do you say it feels hacky? Just to be clear, you don't need to call GetOrSet
for each item when you are prefetching the entire thing at the beginning, you only need to call GetOrSet
later on when you need some of those values and, in that moment, the GetOrSet
means "get me X from the cache and, if it is not there, load it and set it".
Maybe you are thinking about calling GetOrSet
for each key in the initial prefetching phase? If that is the case, that is not necessary.
So, to recap:
- INITIAL PREFETCHING: load all items from db -> for each item call
Set
with a reasonable duration - DURING YOUR NORMAL APP USAGE: call
GetOrSet
so that if the value is expired from the cache it will be loaded again
Doing it this way will allow you to have the cache already filled at start + automatically keep some of those items in the cache, based on actual usage.
Let me know if I got this right and if I can help you more.
Hope this helps.
from fusioncache.
ps: if you plan on also using a 2nd layer (distributed cache) keep in mind that the initial prefetching may not be necessary, since the data may already be in the distributed cache because of previous runs.
from fusioncache.
I'm converting this into a discussion.
from fusioncache.
Related Issues (20)
- [FEATURE] Better detection of incoherent `CacheName`s options HOT 4
- [QUESTION] Can I use FusionCache only for getting data from a 2nd level (distributed) without InMemory part? HOT 5
- [FEATURE] 📢 Add `IgnoreIncomingBackplaneNotifications` options HOT 2
- [FEATURE] Improve nullable for GetOrSet with non-null factory HOT 8
- Explicitly tell the Factory that it failed HOT 9
- [FEATURE] Combination of eager refresh with distributed cache duration. HOT 5
- [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
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.