Adapt Store::get()/Store::create() to check cache before FS
With this change, the cache is tested before accessing the filesystem, which probably increases the speed if the cache has the entry, because we avoid the slow IO operation. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
becfcd4180
commit
88a4eee087
1 changed files with 5 additions and 4 deletions
|
@ -223,12 +223,12 @@ impl Store {
|
||||||
debug!("Creating id: '{}'", id);
|
debug!("Creating id: '{}'", id);
|
||||||
|
|
||||||
let exists =
|
let exists =
|
||||||
self.backend.exists(&id.clone().into_pathbuf()?)? ||
|
|
||||||
self.entries
|
self.entries
|
||||||
.read()
|
.read()
|
||||||
.map(|map| map.contains_key(&id))
|
.map(|map| map.contains_key(&id))
|
||||||
.map_err(|_| Error::from(EM::LockError))
|
.map_err(|_| Error::from(EM::LockError))
|
||||||
.context(format_err!("CreateCallError: {}", id))?;
|
.context(format_err!("CreateCallError: {}", id))? ||
|
||||||
|
self.backend.exists(&id.clone().into_pathbuf()?)?;
|
||||||
|
|
||||||
if exists {
|
if exists {
|
||||||
debug!("Entry exists: {:?}", id);
|
debug!("Entry exists: {:?}", id);
|
||||||
|
@ -307,12 +307,13 @@ impl Store {
|
||||||
debug!("Getting id: '{}'", id);
|
debug!("Getting id: '{}'", id);
|
||||||
|
|
||||||
let exists =
|
let exists =
|
||||||
self.backend.exists(&id.clone().into_pathbuf()?)? ||
|
|
||||||
self.entries
|
self.entries
|
||||||
.read()
|
.read()
|
||||||
.map(|map| map.contains_key(&id))
|
.map(|map| map.contains_key(&id))
|
||||||
.map_err(|_| Error::from(EM::LockError))
|
.map_err(|_| Error::from(EM::LockError))
|
||||||
.context(format_err!("CreateCallError: {}", id))?;
|
.context(format_err!("CreateCallError: {}", id))? ||
|
||||||
|
self.backend.exists(&id.clone().into_pathbuf()?)?;
|
||||||
|
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
debug!("Does not exist in internal cache or filesystem: {:?}", id);
|
debug!("Does not exist in internal cache or filesystem: {:?}", id);
|
||||||
|
|
Loading…
Reference in a new issue