fetch
, obtain
, get
, what should we use for fetching the value of a key?
#1023
-
In the tests, there are three methods for fetching the value of a key. let e5 = hybrid.fetch(5, || async move { Ok(vec![5; 7 * KB]) }).await.unwrap();
assert_eq!(e5.value(), &vec![5; 7 * KB]);
let e1g = hybrid.get(&1).await.unwrap().unwrap();
assert_eq!(e1g.value(), &vec![1; 7 * KB]);
let e2g = hybrid.obtain(2).await.unwrap().unwrap();
assert_eq!(e2g.value(), &vec![2; 7 * KB]); As I understand, |
Beta Was this translation helpful? Give feedback. 8000
Replies: 1 comment 1 reply
-
Hi. In most cases, you may want to use If you don't want foyer to help you fetch value from the remote storage, please use If your system handles request deduplication and don't want to introduce any unnecessary overhead in the foyer layer (e.g. lock overhead for deduplication), In short, please consider |
Beta Was this translation helpful? Give feedback.
Hi.
In most cases, you may want to use
fetch()
over the other two methods.fetch()
handles fetching the desired value from the remote storage and cache filling automatically, which provides the simplest API to handle all complex operations in one.If you don't want foyer to help you fetch value from the remote storage, please use
obtain()
, which performs disk read deduplication to reduce disk IO and returns a miss on a hybrid cache miss.If your system handles request deduplication and don't want to introduce any unnecessary overhead in the foyer layer (e.g. lock overhead for deduplication),
get()
is what you want.In short, please consider
fetch()
>obtaion()
>get()
.