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

Remove some dependencies #141

Merged
merged 3 commits into from
May 28, 2022
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
12 changes: 7 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ build = "build.rs"
default = ["atomic64", "quanta"]

# Enable this feature to use `moka::future::Cache`.
future = ["async-io", "async-lock", "futures-util"]
future = ["async-io", "async-lock", "futures-util", "crossbeam-epoch", "thiserror", "uuid"]

sync = ["crossbeam-epoch", "thiserror", "uuid"]

# Enable this feature to use **experimental** `moka::dash::Cache`.
# Please note that the APIs for this feature will be frequently changed in next
Expand All @@ -39,16 +41,16 @@ unstable-debug-counters = ["future"]

[dependencies]
crossbeam-channel = "0.5.4"
crossbeam-epoch = "0.8.2"
crossbeam-epoch = { version = "0.8.2", optional = true }
crossbeam-utils = "0.8"
num_cpus = "1.13"
once_cell = "1.7"
parking_lot = "0.12"
scheduled-thread-pool = "0.2.5"
scheduled-thread-pool = "0.2.6"
smallvec = "1.8"
tagptr = "0.2"
thiserror = "1.0"
uuid = { version = "0.8", features = ["v4"] }
thiserror = { version = "1.0", optional = true }
uuid = { version = "0.8", features = ["v4"], optional = true }

# Opt-out serde and stable_deref_trait features
# https://github.com/Manishearth/triomphe/pull/5
Expand Down
1 change: 1 addition & 0 deletions src/common/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/// [`Cache#invalidate_entries_if`][invalidate-if] method.
///
/// [invalidate-if]: ./sync/struct.Cache.html#method.invalidate_entries_if
#[cfg(any(feature="sync", feature="future"))]
#[derive(thiserror::Error, Debug)]
pub enum PredicateError {
/// This cache does not have a necessary configuration enabled to support
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ pub mod dash;
#[cfg(feature = "future")]
#[cfg_attr(docsrs, doc(cfg(feature = "future")))]
pub mod future;

#[cfg(any(feature="sync", feature="future"))]
pub mod sync;
pub mod unsync;

#[cfg(any(feature="sync", feature="future"))]
pub(crate) mod cht;
pub(crate) mod common;
pub(crate) mod policy;

#[cfg(any(feature="sync", feature="future"))]
pub use common::error::PredicateError;
pub use policy::Policy;

Expand Down
1 change: 1 addition & 0 deletions src/sync/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use std::{
/// // after 30 minutes (TTL) from the insert().
/// ```
///
#[cfg(feature="sync")]
#[must_use]
pub struct CacheBuilder<K, V, C> {
max_capacity: Option<u64>,
Expand Down
1 change: 1 addition & 0 deletions src/sync/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ use std::{
/// [build-with-hasher-method]: ./struct.CacheBuilder.html#method.build_with_hasher
/// [ahash-crate]: https://crates.io/crates/ahash
///
#[cfg(feature="sync")]
pub struct Cache<K, V, S = RandomState> {
base: BaseCache<K, V, S>,
value_initializer: Arc<ValueInitializer<K, V, S>>,
Expand Down
1 change: 1 addition & 0 deletions src/sync/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use std::{
///
/// [cache-struct]: ./struct.Cache.html
///
#[cfg(feature="sync")]
pub struct SegmentedCache<K, V, S = RandomState> {
inner: Arc<Inner<K, V, S>>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/sync/value_initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub(crate) enum InitResult<V, E> {
ReadExisting(V),
InitErr(Arc<E>),
}

#[cfg(feature="sync")]
pub(crate) struct ValueInitializer<K, V, S> {
// TypeId is the type ID of the concrete error type of generic type E in
// try_init_or_read(). We use the type ID as a part of the key to ensure that
Expand Down