CachedStorage

Struct CachedStorage 

Source
pub struct CachedStorage<S> { /* private fields */ }
Expand description

Cached storage wrapper.

Wraps any storage backend with an LRU cache for improved read performance.

Implementations§

Source§

impl<S> CachedStorage<S>

Source

pub fn new(inner: S, config: CacheConfig) -> Self

Creates a new cached storage wrapper.

Source

pub fn with_defaults(inner: S) -> Self

Creates a cached storage with default configuration.

Source

pub fn inner(&self) -> &S

Returns the underlying storage.

Source

pub fn config(&self) -> &CacheConfig

Returns the cache configuration.

Source

pub fn stats(&self) -> CacheStats

Returns current cache statistics.

Source

pub fn clear(&self)

Clears the cache.

Source

pub fn invalidate(&self, id: &ObjectId)

Invalidates a specific object from the cache.

Source§

impl<S> CachedStorage<S>

Source

pub fn get(&self, id: &ObjectId) -> Result<Option<GitObject>>

Gets an object, checking cache first.

Source

pub fn put(&self, object: GitObject) -> Result<ObjectId>

Puts an object, optionally caching it.

Source

pub fn contains(&self, id: &ObjectId) -> Result<bool>

Checks if an object exists.

Source

pub fn delete(&self, id: &ObjectId) -> Result<bool>

Deletes an object.

Source

pub fn len(&self) -> Result<usize>

Returns the number of objects.

Source

pub fn is_empty(&self) -> Result<bool>

Returns true if empty.

Source

pub fn list_objects(&self) -> Result<Vec<ObjectId>>

Lists all object IDs.

Source

pub fn batch_get(&self, ids: &[ObjectId]) -> Result<Vec<Option<GitObject>>>

Batch get with caching.

Trait Implementations§

Source§

impl<S> ObjectStoreBackend for CachedStorage<S>

Source§

fn put(&self, object: GitObject) -> Result<ObjectId>

Stores an object and returns its ID.
Source§

fn get(&self, id: &ObjectId) -> Result<Option<GitObject>>

Retrieves an object by ID.
Source§

fn contains(&self, id: &ObjectId) -> Result<bool>

Checks if an object exists.
Source§

fn delete(&self, id: &ObjectId) -> Result<bool>

Deletes an object by ID.
Source§

fn len(&self) -> Result<usize>

Returns the number of objects in the store.
Source§

fn list_objects(&self) -> Result<Vec<ObjectId>>

Lists all object IDs.
Source§

fn batch_get(&self, ids: &[ObjectId]) -> Result<Vec<Option<GitObject>>>

Batch get operation.
Source§

fn flush(&self) -> Result<()>

Flush any pending writes to durable storage.
Source§

fn is_empty(&self) -> Result<bool>

Returns true if the store is empty.
Source§

fn batch_put(&self, objects: Vec<GitObject>) -> Result<Vec<ObjectId>>

Batch put operation for improved throughput.
Source§

fn compact(&self) -> Result<()>

Compact the storage to reclaim space.

Auto Trait Implementations§

§

impl<S> !Freeze for CachedStorage<S>

§

impl<S> !RefUnwindSafe for CachedStorage<S>

§

impl<S> Send for CachedStorage<S>
where S: Send,

§

impl<S> Sync for CachedStorage<S>
where S: Sync,

§

impl<S> Unpin for CachedStorage<S>
where S: Unpin,

§

impl<S> UnwindSafe for CachedStorage<S>
where S: UnwindSafe,

Blanket Implementations§

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

Source§

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.