Making .NET 7’s NEW output cache scale with Redis

preview_player
Показать описание

Hello everybody I'm Nick and in this video I will show you how you can integrate Redis into .NET 7's brand new output caching. Using a distributed cache that is extremely fast and scalable, like Redis, will allow you application to scale horizontaly while using one single cache for all your responses.

Don't forget to comment, like and subscribe :)

Social Media:

#csharp #dotnet #caching
Рекомендации по теме
Комментарии
Автор

Thank you, I was waiting for this one :) Now please also make a video how to make the new rate limiting shared via redis and then we have everything we need from an expert!

Arkensor
Автор

Thank you for the great video!
I think there are some major problems with the implementation.
The tag and key may collide, its better to prefix the redis keys just in case.
Another thing is a potential race condition if set and revoke are called concurrently the tag redis key may be set before the revoke method reads it, then the revoke will delete the tag key and the cache key in redis wont be revokeable (because there will be no tag redis key)
Switching the order or operations in the set method soves the problem if the redis is a single instance, in case of redis cluster its harder to solve

IceQub
Автор

Great video. A good practice for production environment could be to have a InMemoryCache as first level and RedisCache as second level to combine both worlds.

waltavista
Автор

I liked the video, it's a great example of how to find solutions where there is not official support. At this point there is package from Microsoft:

juanprosales
Автор

That's what i have been waiting for!!

gordonfreimann
Автор

Nice, looking forward for an official implementation

antonmartyniuk
Автор

Awesome 😎 great video. It is very useful.

arumugamkandhasamy
Автор

Thanks Nick. Do you know how we cache authenticated requests?

adamdiament
Автор

Great stuff. Finally memoization is making it into .NET alongside endpoints defined by lambdas 😂

I'm not so sure though why you'd ever want to lock the cache. By the CAP theorem, given your app is distributed, you cannot drop partition tolerance. So you only have the choice between dropping availability vs. consistency (and I'd always drop consistency for better performance / simpler code if my use case doesn't require it) 🤔

So, your implementation is totally fine. Go find a funny package name and upload it 😉 Guys dealing with distributed consistency will be smart enough to cope with the complexity of event-driven architectures, etc. 😂

marcotroster
Автор

For the MemoryOutputCahceStore, any idea why they'd choose to use a dictionary and do their own locking over using a ConcurrentDictionary?

SlackwareNVM
Автор

I am new to this one, in why decalre two static functions with same name and basically same content inside it?

public static IServiceCollection AddRedisOutputCache one with service and one with service + options (so it can uses the option)

I know this is from the original but why is that? anyone can explain?

johnli
Автор

Couldn't find the previous video can you send here please thanks

oguzhan
Автор

Is there a way to cache responoses for authenticated user using JWT Token? I know it’s a bad practice to cache responses when JWT is present since the data may vary based on the user, but i was wondering if there is a way to cache the response for individual users? And is it even a good practice to do so?

bshwanmuhamad
Автор

Hello, In .NET 6 output caching can't be used for Auhorized Controllers. Is possible in .NET 7?

juliangzr
Автор

Just catching this one but it would have been a perfect example to implement using TDD/BDD, you knew exactly the response that would have been a pass for the created test. And you could have taken it even further with a test that validates caching logic is working as expected.

aurinator
Автор

Hey Nick great video,

With regards to the lock statements that you wanted to implement, I was wondering why not to use SemaphoreSlim since the code is already asynchronous? Are there any performance traps related to it?

abi
Автор

Have you tried to plug IDistributedCache, rather than deal with Redis specific abstractions, in order to abstract away the caching provider?

felixpelletier
Автор

Hi, Where is this video source code?!

msafari
Автор

I'd really like to use output cache in my code, the evictByTag is required for my use case. But I'd need to convince my project manager to use .NET7. I hope they'll release this component as a nuget library that can be used in .NET6.

astralpowers
Автор

Impressive but as you say I imagine MS will provide connectors to 3rd party caching platforms at release of 7.0

EmptyGlass
welcome to shbcf.ru