Skip to content

Commit d0088d6

Browse files
authored
Create ef-core-query-cache-control.md
1 parent 48253f5 commit d0088d6

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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)

0 commit comments

Comments
 (0)