pub type Handle = Cache<Handle<OwnShared<Store>>>;
Expand description
A thread-local handle to access any object.
Aliased Type§
struct Handle { /* private fields */ }
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> 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.