diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2018-11-06 18:22:11 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2018-11-06 18:35:17 +0100 |
commit | 88a4eee08760fcb59453f7b69f5d0b7ff300705d (patch) | |
tree | d91c25318c8caa362807d9bc5a1f0e34b1edb4a8 /lib/core | |
parent | becfcd41807bf65fb6f8543800bb57d7e8e93d7a (diff) |
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>
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/libimagstore/src/store.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/core/libimagstore/src/store.rs b/lib/core/libimagstore/src/store.rs index 91cee863..36904a3b 100644 --- a/lib/core/libimagstore/src/store.rs +++ b/lib/core/libimagstore/src/store.rs @@ -223,12 +223,12 @@ impl Store { debug!("Creating id: '{}'", id); let exists = - self.backend.exists(&id.clone().into_pathbuf()?)? || self.entries .read() .map(|map| map.contains_key(&id)) .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 { debug!("Entry exists: {:?}", id); @@ -307,12 +307,13 @@ impl Store { debug!("Getting id: '{}'", id); let exists = - self.backend.exists(&id.clone().into_pathbuf()?)? || self.entries .read() .map(|map| map.contains_key(&id)) .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 { debug!("Does not exist in internal cache or filesystem: {:?}", id); |