Struct gix_odb::Cache

source ·
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 Cache<Handle<Rc<Store>>>

source

pub fn into_arc(self) -> Result<Cache<Handle<Arc<Store>>>>

Convert this cache’s handle into one that keeps its store in an arc. This creates an entirely new store, so should be done early to avoid unnecessary work (and mappings).

source§

impl Cache<Handle<Arc<Store>>>

source

pub fn into_arc(self) -> Result<Cache<Handle<Arc<Store>>>>

No op, as we are containing an arc handle already.

source§

impl<S> Cache<S>

source

pub fn into_inner(self) -> S

Dissolve this instance, discard all caches, and return the inner implementation.

source

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.

source

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.

source

pub fn set_pack_cache( &mut self, create: impl Fn() -> Box<PackCache> + Send + Sync + 'static )

Set the pack cache constructor on this instance.

source

pub fn set_object_cache( &mut self, create: impl Fn() -> Box<ObjectCache> + Send + Sync + 'static )

Set the object cache constructor on this instance.

source

pub fn has_object_cache(&self) -> bool

Return true if an object cache is present.

source

pub fn has_pack_cache(&self) -> bool

Return true if a pack cache is present.

source

pub fn unset_pack_cache(&mut self)

Remove the current pack cache as well as its constructor from this instance.

source

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: Clone> Clone for Cache<S>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<S> Deref for Cache<S>

§

type Target = S

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<S> DerefMut for Cache<S>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<S> Exists for Cache<S>
where S: Find,

source§

fn exists(&self, id: &oid) -> bool

Returns true if the object exists in the database.
source§

impl<S> Find for Cache<S>
where S: Find,

source§

fn contains(&self, id: &oid) -> bool

Returns true if the object exists in the database.
source§

fn try_find<'a>( &self, id: &oid, buffer: &'a mut Vec<u8> ) -> Result<Option<(Data<'a>, Option<Location>)>, Error>

Find an object matching 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 more
source§

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>

Like 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 more
source§

fn location_by_oid(&self, id: &oid, buf: &mut Vec<u8>) -> Option<Location>

Find the packs location where an object with id can be found in the database, or None if there is no pack holding the object. Read more
source§

fn pack_offsets_and_oid(&self, pack_id: u32) -> Option<Vec<(u64, ObjectId)>>

Obtain a vector of all offsets, in index order, along with their object id.
source§

fn entry_by_location(&self, location: &Location) -> Option<Entry>

Return the find::Entry for location if it is backed by a pack. Read more
source§

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>>, Error>

Find an object matching id in the database while placing its raw, possibly encoded data into buffer. Read more
source§

impl<S> Header for Cache<S>
where S: FindHeader,

source§

fn try_header(&self, id: &oid) -> Result<Option<Header>, Error>

Find the header of the object matching id in the database. Read more
source§

impl<S> From<S> for Cache<S>
where S: Find,

source§

fn from(store: S) -> Self

Converts to this type from the input type.
source§

impl<S> Header for Cache<S>
where S: Header,

source§

fn try_header(&self, id: &oid) -> Result<Option<Header>, Error>

Try to read the header of the object associated with id or return None if it could not be found.
source§

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>

As write, but takes an input stream. This is commonly used for writing blobs directly without reading them to memory first.
source§

fn write(&self, object: &dyn WriteTo) -> Result<ObjectId, Error>

Write objects using the intrinsic kind of hash into the database, returning id to reference it in subsequent reads.
source§

fn write_buf(&self, object: Kind, from: &[u8]) -> Result<ObjectId, Error>

As write, but takes an object kind along with its encoded bytes.

Auto Trait Implementations§

§

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, A, P> Access<T> for P
where A: Access<T> + ?Sized, P: Deref<Target = A>,

§

type Guard = <A as Access<T>>::Guard

A guard object containing the value and keeping it alive. Read more
source§

fn load(&self) -> <P as Access<T>>::Guard

The loading method. Read more
source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, A> DynAccess<T> for A
where A: Access<T>, <A as Access<T>>::Guard: 'static,

source§

fn load(&self) -> DynGuard<T>

The equivalent of Access::load.
source§

impl<T> FindExt for T
where T: Find + ?Sized,

source§

fn find<'a>( &self, id: &oid, buffer: &'a mut Vec<u8> ) -> Result<(Data<'a>, Option<Location>), Error>

Like 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>

Like 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>

Like 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>

Like 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>

Like 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>

Like 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>, Option<Location>), Error>

Like 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>, Option<Location>), Error>

Like 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
where T: Find + ?Sized,

source§

fn find<'a>(&self, id: &oid, buffer: &'a mut Vec<u8>) -> Result<Data<'a>, Error>

Like 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>

Like 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>

Like 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>

Like 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>

Like 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>

Like 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>

Like 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>

Like 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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> HeaderExt for T
where T: Header,

source§

fn header(&self, id: impl AsRef<oid>) -> Result<Header, Error>

Like try_header(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error.
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> FindObjectOrHeader for T
where T: Find + Header,

§

impl<T> Formattable for T
where T: Deref, <T as Deref>::Target: Formattable,

§

impl<T> Parsable for T
where T: Deref, <T as Deref>::Target: Parsable,