Skip to content

Commit adddf8f

Browse files
authored
deps: bump cached to 0.58 (#3594)
* deps: bump cachec to 0.58 and remove git dependency; update lock file * refactor: adjust to cached 0.58 breaking changes cached 0.58 switched from std::sync::Mutex to parking_lot::Mutex. parking_lot::Mutex::lock() returns MutexGuard directly (not Result), so .unwrap() and Ok/Err pattern matching are no longer valid.
1 parent 3fa8e06 commit adddf8f

File tree

5 files changed

+34
-37
lines changed

5 files changed

+34
-37
lines changed

Cargo.lock

Lines changed: 16 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ bytemuck = { version = "1.24", features = [
9191
], optional = true }
9292
byteorder = "1.5"
9393
bytes = "1"
94-
cached = { version = "0.56", features = [
94+
cached = { version = "0.58", features = [
9595
"ahash",
9696
"disk_store",
9797
"redis_ahash",
@@ -331,9 +331,6 @@ csv-index = { git = "https://github.com/dathere/rust-csv", branch = "qsv-tuned"
331331
# csv-core = { path = "../rust-csv/csv-core" }
332332
# csv-index = { path = "../rust-csv/csv-index" }
333333

334-
# use fork with updated redis 1.0 dependency & client-side caching features
335-
cached = { git = "https://github.com/nihohit/cached", branch = "client-side-caching" }
336-
337334
# use our patched fork to bump dependencies until our PR is merged
338335
csvlens = { git = "https://github.com/jqnatividad/csvlens", branch = "bump-deps-202602" }
339336

src/cmd/fetch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
837837
final_response = intermediate_value.value;
838838
was_cached = intermediate_value.was_cached;
839839
if !args.flag_cache_error && final_response.status_code != 200 {
840-
let mut cache = GET_CACHED_RESPONSE.lock().unwrap();
840+
let mut cache = GET_CACHED_RESPONSE.lock();
841841
cache.cache_remove(&url);
842842
}
843843
},

src/cmd/fetchpost.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
907907
final_response = intermediate_value.value;
908908
was_cached = intermediate_value.was_cached;
909909
if !args.flag_cache_error && final_response.status_code != 200 {
910-
let mut cache = GET_CACHED_RESPONSE.lock().unwrap();
910+
let mut cache = GET_CACHED_RESPONSE.lock();
911911
cache.cache_remove(&url);
912912
}
913913
},

src/util.rs

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -814,25 +814,21 @@ macro_rules! update_cache_info {
814814
use cached::Cached;
815815
use indicatif::HumanCount;
816816

817-
match $cache_instance.lock() {
818-
Ok(cache) => {
819-
let size = cache.cache_size();
820-
if size > 0 {
821-
let hits = cache.cache_hits().unwrap_or_default();
822-
let misses = cache.cache_misses().unwrap_or(1);
823-
#[allow(clippy::cast_precision_loss)]
824-
let hit_ratio = (hits as f64 / (hits + misses) as f64) * 100.0;
825-
let capacity = cache.cache_capacity();
826-
$progress.set_message(format!(
827-
" of {} records. Cache {:.2}% entries: {} capacity: {}.",
828-
HumanCount($progress.length().unwrap()),
829-
hit_ratio,
830-
HumanCount(size as u64),
831-
HumanCount(capacity.unwrap() as u64),
832-
));
833-
}
834-
},
835-
_ => {},
817+
let cache = $cache_instance.lock();
818+
let size = cache.cache_size();
819+
if size > 0 {
820+
let hits = cache.cache_hits().unwrap_or_default();
821+
let misses = cache.cache_misses().unwrap_or(1);
822+
#[allow(clippy::cast_precision_loss)]
823+
let hit_ratio = (hits as f64 / (hits + misses) as f64) * 100.0;
824+
let capacity = cache.cache_capacity();
825+
$progress.set_message(format!(
826+
" of {} records. Cache {:.2}% entries: {} capacity: {}.",
827+
HumanCount($progress.length().unwrap()),
828+
hit_ratio,
829+
HumanCount(size as u64),
830+
HumanCount(capacity.unwrap() as u64),
831+
));
836832
}
837833
};
838834
($progress:expr_2021, $cache_hits:expr_2021, $num_rows:expr_2021) => {

0 commit comments

Comments
 (0)