-
Notifications
You must be signed in to change notification settings - Fork 249
Expand file tree
/
Copy pathSampleController.cs
More file actions
165 lines (139 loc) · 4.42 KB
/
SampleController.cs
File metadata and controls
165 lines (139 loc) · 4.42 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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
using WebApi.OutputCache.V2.TimeAttributes;
namespace WebApi.OutputCache.V2.Tests.TestControllers
{
public class SampleController : ApiController
{
[CacheOutput(ClientTimeSpan = 100, ServerTimeSpan = 100)]
public string Get_c100_s100()
{
return "test";
}
[CacheOutput(ClientTimeSpan = 100, ServerTimeSpan = 0)]
public string Get_c100_s0()
{
return "test";
}
[CacheOutput(ClientTimeSpan = 0, ServerTimeSpan = 100)]
public string Get_c0_s100()
{
return "test";
}
[CacheOutput(NoCache = true)]
public string Get_nocache()
{
return "test";
}
[CacheOutput(ClientTimeSpan = 0, ServerTimeSpan = 100, MustRevalidate = true)]
public string Get_c0_s100_mustR()
{
return "test";
}
[CacheOutput(ClientTimeSpan = 50, MustRevalidate = true)]
public string Get_c50_mustR()
{
return "test";
}
[CacheOutput(ClientTimeSpan = 50, Private = true)]
public string Get_c50_private()
{
return "test";
}
[CacheOutput(Private = true)]
public string Get_private()
{
return "test";
}
[CacheOutput(ServerTimeSpan = 50)]
public string Get_s50_exclude_fakecallback(int? id = null, string callback = null, string de = null)
{
return "test";
}
[CacheOutput(ServerTimeSpan = 50, ExcludeQueryStringFromCacheKey = false)]
public string Get_s50_exclude_false(int id)
{
return "test" + id;
}
[CacheOutput(ServerTimeSpan = 50, ExcludeQueryStringFromCacheKey = true)]
public string Get_s50_exclude_true(int id)
{
return "test" + id;
}
[CacheOutputUntil(2020, 01, 25, 17, 00)]
public string Get_until25012020_1700()
{
return "test";
}
[CacheOutputUntilToday(23, 55)]
public string Get_until2355_today()
{
return "value";
}
[CacheOutputUntilThisMonth(27)]
public string Get_until27_thismonth()
{
return "value";
}
[CacheOutputUntilThisYear(7, 31)]
public string Get_until731_thisyear()
{
return "value";
}
[CacheOutputUntilThisYear(7, 31, MustRevalidate = true)]
public string Get_until731_thisyear_mustrevalidate()
{
return "value";
}
[CacheOutput(AnonymousOnly = true, ClientTimeSpan = 50, ServerTimeSpan = 50)]
public string Get_s50_c50_anonymousonly()
{
return "value";
}
[HttpGet]
[CacheOutput(AnonymousOnly = true, ClientTimeSpan = 50, ServerTimeSpan = 50)]
public string etag_match_304()
{
return "value";
}
[CacheOutput(ClientTimeSpan = 50, ServerTimeSpan = 50)]
public string Get_request_exception_noCache()
{
throw new System.Exception("Fault shouldn't cache");
}
[CacheOutput(ClientTimeSpan = 50, ServerTimeSpan = 50)]
public string Get_request_httpResponseException_noCache()
{
throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Conflict) { ReasonPhrase = "Fault shouldn't cache" });
}
[CacheOutput(ClientTimeSpan = 50, ServerTimeSpan = 50)]
public HttpResponseMessage Get_request_noContent()
{
return Request.CreateResponse(HttpStatusCode.Accepted);
}
[InvalidateCacheOutput("Get_c100_s100")]
public void Post()
{
//do nothing
}
[InvalidateCacheOutput("Get_c100_s100")]
[InvalidateCacheOutput("Get_s50_exclude_fakecallback")]
public void Post_2_invalidates()
{
//do nothing
}
[CacheOutput(ClientTimeSpan = 100, ServerTimeSpan = 100)]
public IHttpActionResult Get_ihttpactionresult()
{
return Ok("value");
}
[CacheOutput(ClientTimeSpan = 100, ServerTimeSpan = 100, SharedTimeSpan = 200)]
public string Get_c100_s100_sm200()
{
return "test";
}
}
}