@@ -31,9 +31,9 @@ mod rust_version;
31
31
mod teams;
32
32
33
33
use cache:: Cache ;
34
+ use cache:: Cached ;
34
35
use production:: User ;
35
36
use rocket:: tokio:: sync:: RwLock ;
36
- use rocket:: State ;
37
37
use rust_version:: RustReleasePost ;
38
38
use rust_version:: RustVersion ;
39
39
use teams:: encode_zulip_stream;
@@ -190,17 +190,17 @@ fn robots_txt() -> Option<content::RawText<&'static str>> {
190
190
191
191
#[ get( "/" ) ]
192
192
async fn index (
193
- version_cache : & State < Arc < RwLock < RustVersion > > > ,
194
- release_post_cache : & State < Arc < RwLock < RustReleasePost > > > ,
193
+ version_cache : & Cache < RustVersion > ,
194
+ release_post_cache : & Cache < RustReleasePost > ,
195
195
) -> Template {
196
196
render_index ( ENGLISH . into ( ) , version_cache, release_post_cache) . await
197
197
}
198
198
199
199
#[ get( "/<locale>" , rank = 3 ) ]
200
200
async fn index_locale (
201
201
locale : SupportedLocale ,
202
- version_cache : & State < Arc < RwLock < RustVersion > > > ,
203
- release_post_cache : & State < Arc < RwLock < RustReleasePost > > > ,
202
+ version_cache : & Cache < RustVersion > ,
203
+ release_post_cache : & Cache < RustReleasePost > ,
204
204
) -> Template {
205
205
render_index ( locale. 0 , version_cache, release_post_cache) . await
206
206
}
@@ -216,23 +216,23 @@ fn category_locale(category: Category, locale: SupportedLocale) -> Template {
216
216
}
217
217
218
218
#[ get( "/governance" ) ]
219
- async fn governance ( teams_cache : & State < Arc < RwLock < RustTeams > > > ) -> Result < Template , Status > {
219
+ async fn governance ( teams_cache : & Cache < RustTeams > ) -> Result < Template , Status > {
220
220
render_governance ( ENGLISH . into ( ) , teams_cache) . await
221
221
}
222
222
223
223
#[ get( "/governance/<section>/<team>" , rank = 2 ) ]
224
224
async fn team (
225
225
section : String ,
226
226
team : String ,
227
- teams_cache : & State < Arc < RwLock < RustTeams > > > ,
227
+ teams_cache : & Cache < RustTeams > ,
228
228
) -> Result < Template , Result < Redirect , Status > > {
229
229
render_team ( section, team, ENGLISH . into ( ) , teams_cache) . await
230
230
}
231
231
232
232
#[ get( "/<locale>/governance" , rank = 8 ) ]
233
233
async fn governance_locale (
234
234
locale : SupportedLocale ,
235
- teams_cache : & State < Arc < RwLock < RustTeams > > > ,
235
+ teams_cache : & Cache < RustTeams > ,
236
236
) -> Result < Template , Status > {
237
237
render_governance ( locale. 0 , teams_cache) . await
238
238
}
@@ -242,7 +242,7 @@ async fn team_locale(
242
242
section : String ,
243
243
team : String ,
244
244
locale : SupportedLocale ,
245
- teams_cache : & State < Arc < RwLock < RustTeams > > > ,
245
+ teams_cache : & Cache < RustTeams > ,
246
246
) -> Result < Template , Result < Redirect , Status > > {
247
247
render_team ( section, team, locale. 0 , teams_cache) . await
248
248
}
@@ -368,8 +368,8 @@ fn concat_app_js(files: Vec<&str>) -> String {
368
368
369
369
async fn render_index (
370
370
lang : String ,
371
- version_cache : & State < Arc < RwLock < RustVersion > > > ,
372
- release_post_cache : & State < Arc < RwLock < RustReleasePost > > > ,
371
+ version_cache : & Cache < RustVersion > ,
372
+ release_post_cache : & Cache < RustReleasePost > ,
373
373
) -> Template {
374
374
#[ derive( Serialize ) ]
375
375
struct IndexData {
@@ -414,7 +414,7 @@ fn render_production(lang: String) -> Template {
414
414
415
415
async fn render_governance (
416
416
lang : String ,
417
- teams_cache : & State < Arc < RwLock < RustTeams > > > ,
417
+ teams_cache : & Cache < RustTeams > ,
418
418
) -> Result < Template , Status > {
419
419
match teams:: index_data ( teams_cache) . await {
420
420
Ok ( data) => {
@@ -434,7 +434,7 @@ async fn render_team(
434
434
section : String ,
435
435
team : String ,
436
436
lang : String ,
437
- teams_cache : & State < Arc < RwLock < RustTeams > > > ,
437
+ teams_cache : & Cache < RustTeams > ,
438
438
) -> Result < Template , Result < Redirect , Status > > {
439
439
match teams:: page_data ( & section, & team, teams_cache) . await {
440
440
Ok ( data) => {
0 commit comments