-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCache.cs
More file actions
92 lines (85 loc) · 2.5 KB
/
Cache.cs
File metadata and controls
92 lines (85 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Microsoft.Data.Entity;
using Web.Helpers;
namespace Web.Models
{
public static class Cache
{
private static IList<Page> pages;
public static IList<Page> Pages
{
get
{
if (pages == null)
{
var db = new DB();
pages = db.Pages.ToList();
}
return pages;
}
}
private static IList<Image> images;
public static IList<Image> Images
{
get
{
if (images == null)
{
var db = new DB();
images = db.Images
.Include(i => i.ImageTags)
.ThenInclude(it => it.Tag)
.ThenInclude(t => t.TagType)
.ToList();
}
return images;
}
}
private static IList<Page> frontPagePosts;
public static IList<Page> FrontPagePosts
{
get
{
if (frontPagePosts == null)
{
frontPagePosts = Pages
.Where(p => p.Category.Matches("Blog") && p.Aggregate)
.OrderByDescending(p => p.Timestamp)
.Take(8)
.ToList();
}
return frontPagePosts;
}
}
private static IList<Image> frontPageImages;
public static IList<Image> FrontPageImages
{
get
{
if (frontPageImages == null)
{
frontPageImages = Images
.Where(i => i.Enabled)
.OrderByDescending(i => i.ID)
.Take(8)
.ToList();
}
return frontPageImages;
}
}
[SuppressMessage("ReSharper", "UnusedVariable")]
public static void Flush()
{
pages = null;
images = null;
frontPagePosts = null;
frontPageImages = null;
var a = Pages;
var b = Images;
var c = FrontPagePosts;
var d = FrontPageImages;
}
}
}