pub struct Cache<S> { /* private fields */ }
Expand description
A way to access objects along with pre-configured thread-local caches for packed base objects as well as objects themselves.
By default, no cache will be used.
Implementations§
source§impl<S> Cache<S>
impl<S> Cache<S>
sourcepub fn into_inner(self) -> S
pub fn into_inner(self) -> S
Dissolve this instance, discard all caches, and return the inner implementation.
sourcepub fn with_pack_cache(
self,
create: impl Fn() -> Box<PackCache> + Send + Sync + 'static,
) -> Self
pub fn with_pack_cache( self, create: impl Fn() -> Box<PackCache> + Send + Sync + 'static, ) -> Self
Use this methods directly after creating a new instance to add a constructor for pack caches.
These are used to speed up decoding objects which are located in packs, reducing long delta chains by storing their intermediate results.
sourcepub fn with_object_cache(
self,
create: impl Fn() -> Box<ObjectCache> + Send + Sync + 'static,
) -> Self
pub fn with_object_cache( self, create: impl Fn() -> Box<ObjectCache> + Send + Sync + 'static, ) -> Self
Use this methods directly after creating a new instance to add a constructor for object caches.
Only use this kind of cache if the same objects are repeatedly accessed for great speedups, usually during diffing of trees.
sourcepub fn set_pack_cache(
&mut self,
create: impl Fn() -> Box<PackCache> + Send + Sync + 'static,
)
pub fn set_pack_cache( &mut self, create: impl Fn() -> Box<PackCache> + Send + Sync + 'static, )
Set the pack cache constructor on this instance.
sourcepub fn set_object_cache(
&mut self,
create: impl Fn() -> Box<ObjectCache> + Send + Sync + 'static,
)
pub fn set_object_cache( &mut self, create: impl Fn() -> Box<ObjectCache> + Send + Sync + 'static, )
Set the object cache constructor on this instance.
sourcepub fn has_object_cache(&self) -> bool
pub fn has_object_cache(&self) -> bool
Return true if an object cache is present.
sourcepub fn has_pack_cache(&self) -> bool
pub fn has_pack_cache(&self) -> bool
Return true if a pack cache is present.
sourcepub fn unset_pack_cache(&mut self)
pub fn unset_pack_cache(&mut self)
Remove the current pack cache as well as its constructor from this instance.
sourcepub fn unset_object_cache(&mut self)
pub fn unset_object_cache(&mut self)
Remove the current object cache as well as its constructor from this instance.
Trait Implementations§
source§impl<S> Find for Cache<S>where
S: Find,
impl<S> Find for Cache<S>where
S: Find,
source§fn try_find<'a>(
&self,
id: &oid,
buffer: &'a mut Vec<u8>,
) -> Result<Option<(Data<'a>, Option<Location>)>, Error>
fn try_find<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<Option<(Data<'a>, Option<Location>)>, Error>
id
in the database while placing its raw, decoded data into buffer
.
A pack_cache
can be used to speed up subsequent lookups, set it to crate::cache::Never
if the
workload isn’t suitable for caching. Read moresource§fn try_find_cached<'a>(
&self,
id: &oid,
buffer: &'a mut Vec<u8>,
pack_cache: &mut dyn DecodeEntry,
) -> Result<Option<(Data<'a>, Option<Location>)>, Error>
fn try_find_cached<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, pack_cache: &mut dyn DecodeEntry, ) -> Result<Option<(Data<'a>, Option<Location>)>, Error>
Find::try_find()
, but with support for controlling the pack cache.
A pack_cache
can be used to speed up subsequent lookups, set it to crate::cache::Never
if the
workload isn’t suitable for caching. Read moresource§fn location_by_oid(&self, id: &oid, buf: &mut Vec<u8>) -> Option<Location>
fn location_by_oid(&self, id: &oid, buf: &mut Vec<u8>) -> Option<Location>
id
can be found in the database, or None
if there is no pack
holding the object. Read moresource§fn pack_offsets_and_oid(&self, pack_id: u32) -> Option<Vec<(u64, ObjectId)>>
fn pack_offsets_and_oid(&self, pack_id: u32) -> Option<Vec<(u64, ObjectId)>>
source§impl<S> Header for Cache<S>where
S: FindHeader,
impl<S> Header for Cache<S>where
S: FindHeader,
source§impl<S> Write for Cache<S>where
S: Write,
impl<S> Write for Cache<S>where
S: Write,
source§fn write_stream(
&self,
kind: Kind,
size: u64,
from: &mut dyn Read,
) -> Result<ObjectId, Error>
fn write_stream( &self, kind: Kind, size: u64, from: &mut dyn Read, ) -> Result<ObjectId, Error>
write
, but takes an input stream.
This is commonly used for writing blobs directly without reading them to memory first.Auto Trait Implementations§
impl<S> !Freeze for Cache<S>
impl<S> !RefUnwindSafe for Cache<S>
impl<S> Send for Cache<S>where
S: Send,
impl<S> !Sync for Cache<S>
impl<S> Unpin for Cache<S>where
S: Unpin,
impl<S> !UnwindSafe for Cache<S>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T, A> DynAccess<T> for A
impl<T, A> DynAccess<T> for A
source§fn load(&self) -> DynGuard<T>
fn load(&self) -> DynGuard<T>
Access::load
.source§impl<T> FindExt for T
impl<T> FindExt for T
source§fn find<'a>(
&self,
id: &oid,
buffer: &'a mut Vec<u8>,
) -> Result<(Data<'a>, Option<Location>), Error>
fn find<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<(Data<'a>, Option<Location>), Error>
try_find(…)
, but flattens the Result<Option<_>>
into a single Result
making a non-existing object an error.source§fn find_commit<'a>(
&self,
id: &oid,
buffer: &'a mut Vec<u8>,
) -> Result<(CommitRef<'a>, Option<Location>), Error>
fn find_commit<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<(CommitRef<'a>, Option<Location>), Error>
find(…)
, but flattens the Result<Option<_>>
into a single Result
making a non-existing object an error
while returning the desired object type.source§fn find_tree<'a>(
&self,
id: &oid,
buffer: &'a mut Vec<u8>,
) -> Result<(TreeRef<'a>, Option<Location>), Error>
fn find_tree<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<(TreeRef<'a>, Option<Location>), Error>
find(…)
, but flattens the Result<Option<_>>
into a single Result
making a non-existing object an error
while returning the desired object type.source§fn find_tag<'a>(
&self,
id: &oid,
buffer: &'a mut Vec<u8>,
) -> Result<(TagRef<'a>, Option<Location>), Error>
fn find_tag<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<(TagRef<'a>, Option<Location>), Error>
find(…)
, but flattens the Result<Option<_>>
into a single Result
making a non-existing object an error
while returning the desired object type.source§fn find_blob<'a>(
&self,
id: &oid,
buffer: &'a mut Vec<u8>,
) -> Result<(BlobRef<'a>, Option<Location>), Error>
fn find_blob<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<(BlobRef<'a>, Option<Location>), Error>
find(…)
, but flattens the Result<Option<_>>
into a single Result
making a non-existing object an error
while returning the desired object type.source§fn find_commit_iter<'a>(
&self,
id: &oid,
buffer: &'a mut Vec<u8>,
) -> Result<(CommitRefIter<'a>, Option<Location>), Error>
fn find_commit_iter<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<(CommitRefIter<'a>, Option<Location>), Error>
find(…)
, but flattens the Result<Option<_>>
into a single Result
making a non-existing object an error
while returning the desired iterator type.source§impl<T> FindExt for T
impl<T> FindExt for T
source§fn find<'a>(&self, id: &oid, buffer: &'a mut Vec<u8>) -> Result<Data<'a>, Error>
fn find<'a>(&self, id: &oid, buffer: &'a mut Vec<u8>) -> Result<Data<'a>, Error>
try_find(…)
, but flattens the Result<Option<_>>
into a single Result
making a non-existing object an error.source§fn find_commit<'a>(
&self,
id: &oid,
buffer: &'a mut Vec<u8>,
) -> Result<CommitRef<'a>, Error>
fn find_commit<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<CommitRef<'a>, Error>
find(…)
, but flattens the Result<Option<_>>
into a single Result
making a non-existing object an error
while returning the desired object type.source§fn find_tree<'a>(
&self,
id: &oid,
buffer: &'a mut Vec<u8>,
) -> Result<TreeRef<'a>, Error>
fn find_tree<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<TreeRef<'a>, Error>
find(…)
, but flattens the Result<Option<_>>
into a single Result
making a non-existing object an error
while returning the desired object type.source§fn find_tag<'a>(
&self,
id: &oid,
buffer: &'a mut Vec<u8>,
) -> Result<TagRef<'a>, Error>
fn find_tag<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<TagRef<'a>, Error>
find(…)
, but flattens the Result<Option<_>>
into a single Result
making a non-existing object an error
while returning the desired object type.source§fn find_blob<'a>(
&self,
id: &oid,
buffer: &'a mut Vec<u8>,
) -> Result<BlobRef<'a>, Error>
fn find_blob<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<BlobRef<'a>, Error>
find(…)
, but flattens the Result<Option<_>>
into a single Result
making a non-existing object an error
while returning the desired object type.source§fn find_commit_iter<'a>(
&self,
id: &oid,
buffer: &'a mut Vec<u8>,
) -> Result<CommitRefIter<'a>, Error>
fn find_commit_iter<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<CommitRefIter<'a>, Error>
find(…)
, but flattens the Result<Option<_>>
into a single Result
making a non-existing object an error
while returning the desired iterator type.source§fn find_tree_iter<'a>(
&self,
id: &oid,
buffer: &'a mut Vec<u8>,
) -> Result<TreeRefIter<'a>, Error>
fn find_tree_iter<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<TreeRefIter<'a>, Error>
find(…)
, but flattens the Result<Option<_>>
into a single Result
making a non-existing object an error
while returning the desired iterator type.source§fn find_tag_iter<'a>(
&self,
id: &oid,
buffer: &'a mut Vec<u8>,
) -> Result<TagRefIter<'a>, Error>
fn find_tag_iter<'a>( &self, id: &oid, buffer: &'a mut Vec<u8>, ) -> Result<TagRefIter<'a>, Error>
find(…)
, but flattens the Result<Option<_>>
into a single Result
making a non-existing object an error
while returning the desired iterator type.