Skip to content

Commit 9ab3600

Browse files
authored
Create ef6-query-cache-expiration.md
1 parent 038a5e5 commit 9ab3600

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
Permalink: ef6-query-cache-expiration
3+
---
4+
5+
# EF+ Query Cache Expiration
6+
7+
All common caching features like absolute expiration, sliding expiration, removed callback are supported.
8+
9+
{% include template-example.html %}
10+
```csharp
11+
12+
// using Z.EntityFramework.Plus; // Don't forget to include this.
13+
var ctx = new EntitiesContext();
14+
15+
// Make the query expire after 2 hours of inactivity
16+
17+
// (EF5 | EF6)
18+
var options = new CacheItemPolicy() { SlidingExpiration = TimeSpan.FromHours(2)};
19+
20+
var states = ctx.States.FromCache(options);
21+
22+
```
23+
[Try it](https://dotnetfiddle.net/f57ZoI)

0 commit comments

Comments
 (0)