Skip to content

Commit 7c99034

Browse files
committed
version_id_cacher: Use (String, String) key instead of format!(...)
1 parent 051f303 commit 7c99034

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/app.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct App {
3636
///
3737
/// This is used by the download endpoint to reduce the number of database queries. The
3838
/// `version_id` is only cached under the canonical spelling of the crate name.
39-
pub(crate) version_id_cacher: DashMap<String, i32>,
39+
pub(crate) version_id_cacher: DashMap<(String, String), i32>,
4040

4141
/// Count downloads and periodically persist them in the database
4242
pub downloads_counter: DownloadsCounter,

src/controllers/version/downloads.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ pub fn download(req: &mut dyn RequestExt) -> EndpointResult {
2121

2222
let mut log_metadata = None;
2323

24-
match app
25-
.version_id_cacher
26-
.entry(format!("{}:{}", crate_name, version))
27-
{
24+
let key = (crate_name.to_string(), version.to_string());
25+
match app.version_id_cacher.entry(key) {
2826
// The version_id is cached. This also means that the provided crate_name is canonical
2927
// and that no fixup is necessary before redirecting.
3028
Entry::Occupied(entry) => {

0 commit comments

Comments
 (0)