mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
Implement is_present
directly in MemcacheBlobstore
Summary: When I implement a cachemutex to keep the herd from all trying to write the same blob multiple times, we'll be able to accelerate this. In the short term, move the implementation up to here so that the change will be obvious when it's put up for review. Reviewed By: jsgf Differential Revision: D8318152 fbshipit-source-id: f117c5fd834cab55ace10ac46bffa881457c840a
This commit is contained in:
parent
59ddd45a41
commit
9b98afc9a4
@ -128,4 +128,22 @@ impl<T: Blobstore + Clone> Blobstore for MemcacheBlobstore<T> {
|
||||
|
||||
bs_put.and_then(move |_| mc_put).boxify()
|
||||
}
|
||||
|
||||
fn is_present(&self, key: String) -> BoxFuture<bool, Error> {
|
||||
let mc_check = self.mc_get(&key).map(|blob| blob.is_some());
|
||||
let bs_check = future::lazy({
|
||||
let blobstore = self.blobstore.clone();
|
||||
move || blobstore.is_present(key)
|
||||
});
|
||||
|
||||
mc_check
|
||||
.and_then(|blob| {
|
||||
if blob {
|
||||
Either::A(Ok(true).into_future())
|
||||
} else {
|
||||
Either::B(bs_check)
|
||||
}
|
||||
})
|
||||
.boxify()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user