File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
docs2/pages/ef-core-docs/documentations/query-cache/scenarios Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ Permalink : ef-core-query-cache-control
3+ ---
4+
5+ # EF Query Cache Control
6+
7+ EF+ Cache is very flexible and lets you have full control over the cache.
8+
9+ You can use your own cache:
10+ -core
11+ {% include template-example.html %}
12+ ``` csharp
13+ QueryCacheManager .Cache = new MemoryCache (new MemoryCacheOptions ());
14+ context .Customers .FromCache ().ToList ();
15+
16+ ```
17+ [ Try it] ( https://dotnetfiddle.net/6ISVBT )
18+
19+ You can set default policy
20+
21+ {% include template-example.html %}
22+ ``` csharp
23+
24+ var options = new MemoryCacheEntryOptions () { SlidingExpiration = TimeSpan .FromHours (2 )};
25+ QueryCacheManager .DefaultMemoryCacheEntryOptions = options ;
26+ context .Customers .FromCache ().ToList ();
27+
28+ ```
29+ [ Try it] ( https://dotnetfiddle.net/k1TOWX )
You can’t perform that action at this time.
0 commit comments