Skip to content

Commit

Permalink
Merge pull request #141 from Milo123459/remove-deps
Browse files Browse the repository at this point in the history
Remove some dependencies
  • Loading branch information
tatsuya6502 authored May 28, 2022
2 parents ee069ef + 3410c04 commit 6c11610
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 9 deletions.
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

0 comments on commit 6c11610

Please sign in to comment.