This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCache.cs
138 lines (121 loc) · 3.68 KB
/
Cache.cs
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using ScrewTurn.Wiki.PluginFramework;
namespace ScrewTurn.Wiki
{
/// <summary>
/// Manages data cache.
/// </summary>
public static class Cache
{
/// <summary>
/// Gets the cache provider.
/// </summary>
public static ICacheProviderV30 Provider
{
get { return Collectors.CacheProviderCollector.GetProvider( Settings.DefaultCacheProvider ); }
}
/// <summary>
/// Gets or sets the number of users online.
/// </summary>
public static int OnlineUsers
{
get { return Provider.OnlineUsers; }
set { Provider.OnlineUsers = value; }
}
/// <summary>
/// Clears the pages cache.
/// </summary>
public static void ClearPageCache( )
{
Provider.ClearPageContentCache( );
}
/// <summary>
/// Clears the pseudo cache.
/// </summary>
public static void ClearPseudoCache( )
{
Provider.ClearPseudoCache( );
}
/// <summary>
/// Gets a cached <see cref="T:PageContent" />.
/// </summary>
/// <param name="page">The page to get the content of.</param>
/// <returns>The page content, or <c>null</c>.</returns>
public static PageContent GetPageContent( PageInfo page )
{
if ( page == null ) return null;
return Provider.GetPageContent( page );
}
/// <summary>
/// Gets a cached formatted page content.
/// </summary>
/// <param name="page">The page to get the formatted content of.</param>
/// <returns>The formatted page content, or <c>null</c>.</returns>
public static string GetFormattedPageContent( PageInfo page )
{
if ( page == null ) return null;
return Provider.GetFormattedPageContent( page );
}
/// <summary>
/// Sets the page content in cache.
/// </summary>
/// <param name="page">The page to set the content of.</param>
/// <param name="content">The content.</param>
public static void SetPageContent( PageInfo page, PageContent content )
{
Provider.SetPageContent( page, content );
if ( Provider.PageCacheUsage > Settings.CacheSize )
{
Provider.CutCache( Settings.CacheCutSize );
}
}
/// <summary>
/// Sets the formatted page content in cache.
/// </summary>
/// <param name="page">The page to set the content of.</param>
/// <param name="content">The content.</param>
public static void SetFormattedPageContent( PageInfo page, string content )
{
Provider.SetFormattedPageContent( page, content );
}
/// <summary>
/// Removes a page from the cache.
/// </summary>
/// <param name="page">The page to remove.</param>
public static void RemovePage( PageInfo page )
{
Provider.RemovePage( page );
}
/// <summary>
/// Gets a pseudo cache item value.
/// </summary>
/// <param name="name">The name of the item to get the value of.</param>
/// <returns>The value of the item, or <c>null</c>.</returns>
public static string GetPseudoCacheValue( string name )
{
return Provider.GetPseudoCacheValue( name );
}
/// <summary>
/// Sets a pseudo cache item value.
/// </summary>
/// <param name="name">The name of the item to set the value of.</param>
/// <param name="value">The value of the item.</param>
public static void SetPseudoCacheValue( string name, string value )
{
Provider.SetPseudoCacheValue( name, value );
}
/// <summary>
/// Gets the number of pages currently in the page cache.
/// </summary>
public static int PageCacheUsage
{
get { return Provider.PageCacheUsage; }
}
/// <summary>
/// Gets the number of formatted pages currently in the page cache.
/// </summary>
public static int FormattedPageCacheUsage
{
get { return Provider.FormatterPageCacheUsage; }
}
}
}