3

I have a database (SQL Server for your information but I don't think it's very important) with some tables, and a ASP.NET Core web application who implements Entity Framework Core to manage data.

In my database, I have 4 tables who are very often used and joined to almost each requests, and the data in this tables are very rarely updated, si I would like to put them in cache to not fetch data in database each time, but only for this tables.

How can I do that with Entity Framework Core ?

I read the documentation but I didn't found anything about caching : https://docs.efproject.net/en/latest

3

3 Answers 3

1

You can use StackExchange.Redis cache for that.You just need to store your tables data on it and invalidate it when tables will be updated.That is it.

Here is the Link : StackExchange.Redis

Sign up to request clarification or add additional context in comments.

Comments

0

I don't think you will be able to use "cached" table rows in your EF queries. You can cache tables (in redis, memory - any on your choice), but when you will make queries to your DB - you will need to perform additional manual processing in your code (in server memory) for joining results from EF with cached tables.

Comments

0

AFAIK, EF doesn't have caching. NHibernate however has excellent caching support. It's a little bit painful to have to use EF now instead of NHibernate, but NHibernate doesn't support Core quite yet.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.