Skip to content
Open
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
11 changes: 2 additions & 9 deletions foyer-storage/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::{
any::{Any, TypeId},
borrow::Cow,
fmt::Debug,
hash::Hash,
sync::Arc,
time::Instant,
};
use std::{any::Any, borrow::Cow, fmt::Debug, hash::Hash, sync::Arc, time::Instant};

use equivalent::Equivalent;
use foyer_common::{
Expand Down Expand Up @@ -313,7 +306,7 @@ where

/// If the disk cache is enabled.
pub fn is_enabled(&self) -> bool {
self.inner.engine.type_id() != TypeId::of::<Arc<NoopEngine<K, V, P>>>()
!(self.inner.engine.as_ref() as &dyn Any).is::<NoopEngine<K, V, P>>()
}
}

Expand Down
29 changes: 29 additions & 0 deletions foyer/src/hybrid/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,35 @@ mod tests {
.unwrap()
}

#[test_log::test(tokio::test)]
async fn test_is_hybrid_with_disk_cache() {
let dir = tempfile::tempdir().unwrap();

let cache = HybridCacheBuilder::<u8, u8>::new()
.memory(1)
.storage()
.with_engine_config(BlockEngineConfig::new(
FsDeviceBuilder::new(dir).with_capacity(1).build().unwrap(),
))
.build()
.await
.unwrap();

assert!(cache.is_hybrid());
}

#[test_log::test(tokio::test)]
async fn test_is_hybrid_without_disk_cache() {
let cache = HybridCacheBuilder::<u8, u8>::new()
.memory(1)
.storage()
.build()
.await
.unwrap();

assert!(!cache.is_hybrid());
}

#[test_log::test(tokio::test)]
async fn test_hybrid_cache() {
let dir = tempfile::tempdir().unwrap();
Expand Down
Loading