pub struct TieredObjectStore { /* private fields */ }Expand description
Tiered object store composing a hot (memory) and cold (block) tier.
New objects are written to the hot tier. When the hot tier is full, the least recently used object is demoted to the cold tier. On a hot-tier miss, the cold tier is consulted and matching objects are promoted back to the hot tier.
§Example
use grafos_store::{TieredObjectStore, ObjectStore, FabricUri};
let mut store = TieredObjectStore::new(32, 256, 16)?;
let uri: FabricUri = "fabric://p/b/k".parse()?;
store.put(&uri, b"data", None)?;
let obj = store.get(&uri)?.unwrap();
assert_eq!(obj.data, b"data");Implementations§
Source§impl TieredObjectStore
impl TieredObjectStore
Sourcepub fn new(hot_buckets: usize, cold_blocks: u64, max_hot: usize) -> Result<Self>
pub fn new(hot_buckets: usize, cold_blocks: u64, max_hot: usize) -> Result<Self>
Create a tiered store.
hot_buckets: number of hash map buckets for the hot tiercold_blocks: number of blocks for the cold tiermax_hot: maximum objects in hot tier before LRU eviction
Sourcepub fn checkpoint(&self) -> Result<()>
pub fn checkpoint(&self) -> Result<()>
Checkpoint the cold tier index to block storage.
Source§impl TieredObjectStore
Mutable get with LRU tracking and cold-to-hot promotion.
impl TieredObjectStore
Mutable get with LRU tracking and cold-to-hot promotion.
Trait Implementations§
Source§impl ObjectStore for TieredObjectStore
impl ObjectStore for TieredObjectStore
Source§fn put(
&mut self,
uri: &FabricUri,
data: &[u8],
opts: Option<PutOptions>,
) -> Result<()>
fn put( &mut self, uri: &FabricUri, data: &[u8], opts: Option<PutOptions>, ) -> Result<()>
Store an object at the given URI. Read more
Source§fn get(&self, uri: &FabricUri) -> Result<Option<ObjectData>>
fn get(&self, uri: &FabricUri) -> Result<Option<ObjectData>>
Retrieve an object by URI. Read more
Source§fn head(&self, uri: &FabricUri) -> Result<Option<ObjectInfo>>
fn head(&self, uri: &FabricUri) -> Result<Option<ObjectInfo>>
Retrieve object metadata without reading the data.
Auto Trait Implementations§
impl Freeze for TieredObjectStore
impl !RefUnwindSafe for TieredObjectStore
impl !Send for TieredObjectStore
impl !Sync for TieredObjectStore
impl Unpin for TieredObjectStore
impl !UnwindSafe for TieredObjectStore
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
Mutably borrows from an owned value. Read more