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§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_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_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_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_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_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.