Skip to content

Commit

Permalink
0.49.1
Browse files Browse the repository at this point in the history
fix remove_expired_entries signature
  • Loading branch information
jaemk committed Feb 24, 2024
1 parent 4f92a00 commit 5a0583b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
## Changed
## Removed

## [0.49.1]
## Added
## Changed
- Fix `DiskCache::remove_expired_entries` signature
## Removed

## [0.49.0 / [cached_proc_macro[0.20.0]] ]
## Added
- Add DiskCache store
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cached"
version = "0.49.0"
version = "0.49.1"
authors = ["James Kominick <[email protected]>"]
description = "Generic cache implementations and simplified function memoization"
repository = "https://github.com/jaemk/cached"
Expand Down
6 changes: 3 additions & 3 deletions src/stores/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,18 @@ where
DiskCacheBuilder::new(cache_name)
}

pub fn remove_expired_entries(&self, connection: &Db) {
pub fn remove_expired_entries(&self) {
let now = SystemTime::now();

for (key, value) in connection.iter().flatten() {
for (key, value) in self.connection.iter().flatten() {
if let Ok(cached) = rmp_serde::from_slice::<CachedDiskValue<V>>(&value) {
if let Some(lifetime_seconds) = self.seconds {
if now
.duration_since(cached.created_at)
.unwrap_or(Duration::from_secs(0))
< Duration::from_secs(lifetime_seconds)
{
let _ = connection.remove(key);
let _ = self.connection.remove(key);
}
}
}
Expand Down

0 comments on commit 5a0583b

Please sign in to comment.