State of caching in EFCore 2025
Hi.
Sorry if the question is banal but I have application using EFCore with postgresql for data access.
In my situation whenever I do operation that touches user profile (read/write) I would like to cache the entire user for 10 minutes and then whenever I make changes also apply them to cache and actual db after that, refreshing the 10 minute cache...
I was wondering if there's elegant way of doing this 2025?
what im using is the IMemoryCache and since virtually every request starts with UserId/UserProfile I have a helper method to get that?
Is this the correct approach or there are some more automatic ways of setting this up 2025?
4 Replies
IMemoryCache
is the right way to do it
well if memorycaching is what you need, there is also distributed caching and hybrid caching https://learn.microsoft.com/en-us/aspnet/core/performance/caching/overview?view=aspnetcore-9.0@Adrian if you're willing to invest in a platform to organize your code, there's https://immediateplatform.dev, where you can create a handler to query the data and a cache to cache the response of the handler
not gonna work im developing my own framework with F# and railway oriented programming, EFCore and C# is there but thats it. 🙂
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View