Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: change TTL to TTI and use version ranges #2

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ keywords = ["cache", "object-store", "arrow"]
categories = ["caching"]

[dependencies]
async-trait = "0.1"
async-trait = "~0.1"
bytes = "~1.9"
futures = "0.3"
futures = "~0.3"
log = "~0.4"
moka = { version = "~0.12", features = ["future"] }
num_cpus = "1.16"
Expand Down
8 changes: 4 additions & 4 deletions src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ mod builder;
pub use self::builder::InMemoryCacheBuilder;
use crate::{paging::PageCache, Error, Result};

/// Default memory page size is 8 MB
pub const DEFAULT_PAGE_SIZE: usize = 8 * 1024 * 1024;
const DEFAULT_TIME_TO_LIVE: Duration = Duration::from_secs(60 * 30); // 30 minutes
/// Default memory page size is 16 KB
pub const DEFAULT_PAGE_SIZE: usize = 16 * 1024;
const DEFAULT_TIME_TO_IDLE: Duration = Duration::from_secs(60 * 30); // 30 minutes

/// In-memory [`PageCache`] implementation.
///
Expand Down Expand Up @@ -85,7 +85,7 @@ impl InMemoryCache {
/// - `page_size`: The maximum size of each page.
///
pub fn new(capacity_bytes: usize, page_size: usize) -> Self {
Self::with_params(capacity_bytes, page_size, DEFAULT_TIME_TO_LIVE)
Self::with_params(capacity_bytes, page_size, DEFAULT_TIME_TO_IDLE)
}

/// Create a new cache with a size that is a fraction of the system memory
Expand Down
4 changes: 2 additions & 2 deletions src/memory/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::time::Duration;

use super::{InMemoryCache, DEFAULT_PAGE_SIZE, DEFAULT_TIME_TO_LIVE};
use super::{InMemoryCache, DEFAULT_PAGE_SIZE, DEFAULT_TIME_TO_IDLE};

/// Builder for [`InMemoryCache`]
pub struct InMemoryCacheBuilder {
Expand All @@ -18,7 +18,7 @@ impl InMemoryCacheBuilder {
Self {
capacity,
page_size: DEFAULT_PAGE_SIZE,
time_to_idle: DEFAULT_TIME_TO_LIVE,
time_to_idle: DEFAULT_TIME_TO_IDLE,
}
}

Expand Down