[−][src]Struct sled_extensions::expiring::Tree
A flash-sympathetic persistent lock-free B+ tree
This tree keeps track of insert and update times if requested
Methods
impl<V, E, F> ExpiringTree<V, E, F> where
E: Encoding<HashSet<IVec>> + Encoding<DateTime<Utc>> + 'static,
F: Encoding<V> + 'static, [src]
E: Encoding<HashSet<IVec>> + Encoding<DateTime<Utc>> + 'static,
F: Encoding<V> + 'static,
pub fn cloned(&self) -> Self[src]
Clone for structures where V, E, and F aren't Clone
pub fn transaction<G, R>(&self, g: G) -> TransactionResult<Result<R>> where
G: Fn(ExpiringTransactionalTree<V, E, F>) -> TransactionResult<Result<R>>, [src]
G: Fn(ExpiringTransactionalTree<V, E, F>) -> TransactionResult<Result<R>>,
Perform a multi-key serializable transaction.
Transactions also work on tuples of Trees, preserving serializable ACID semantics! In this example, we treat two trees like a work queue, atomically apply updates to data and move them from the unprocessed Tree to the processed Tree.
pub fn apply_batch(&self, batch: ExpiringBatch<V, F>) -> Result<()>[src]
Create a new batched update that can be atomically applied.
It is possible to apply a Batch in a transaction as well, which is the way you can apply a Batch to multiple Trees atomically.
pub fn cas<K>(
&self,
key: K,
old: Option<V>,
new: Option<V>
) -> Result<Result<(), Option<V>>> where
K: AsRef<[u8]>, [src]
&self,
key: K,
old: Option<V>,
new: Option<V>
) -> Result<Result<(), Option<V>>> where
K: AsRef<[u8]>,
Compare and swap. Capable of unique creation, conditional modification, or deletion. If old is None, this will only set the value if it doesn't exist yet. If new is None, will delete the value if old is correct. If both old and new are Some, will modify the value if old is correct. If Tree is read-only, will do nothing.
pub fn get<K>(&self, key: K) -> Result<Option<V>> where
K: AsRef<[u8]>, [src]
K: AsRef<[u8]>,
Retrieve a value from the Tree if it exists.
pub fn insert<K>(&self, key: K, value: V) -> Result<Option<V>> where
IVec: From<K>,
K: AsRef<[u8]>, [src]
IVec: From<K>,
K: AsRef<[u8]>,
Insert a key to a new value, returning the last value if it was set.
pub fn remove<K>(&self, key: K) -> Result<Option<V>> where
K: AsRef<[u8]>, [src]
K: AsRef<[u8]>,
Delete a value, returning the old value if it existed.
pub fn update_and_fetch<K>(
&self,
key: K,
f: impl Fn(Option<V>) -> Option<V>
) -> Result<Option<V>> where
K: AsRef<[u8]>, [src]
&self,
key: K,
f: impl Fn(Option<V>) -> Option<V>
) -> Result<Option<V>> where
K: AsRef<[u8]>,
Fetch the value, apply a function to it and return the result.
Note
This may call the function multiple times if the value has been changed from other threads in the meantime.
pub fn fetch_and_update<K>(
&self,
key: K,
f: impl Fn(Option<V>) -> Option<V>
) -> Result<Option<V>> where
K: AsRef<[u8]>, [src]
&self,
key: K,
f: impl Fn(Option<V>) -> Option<V>
) -> Result<Option<V>> where
K: AsRef<[u8]>,
Fetch the value, apply a function to it and return the previous value.
Note
This may call the function multiple times if the value has been changed from other threads in the meantime.
pub fn flush(&self) -> Result<()>[src]
Synchronously flushes all dirty IO buffers and calls fsync. If this succeeds, it is guaranteed that all previous writes will be recovered if the system crashes. Returns the number of bytes flushed during this call.
Flushing can take quite a lot of time, and you should measure the performance impact of using it on realistic sustained workloads running on realistic hardware.
pub fn contains_key<K>(&self, key: K) -> Result<bool> where
K: AsRef<[u8]>, [src]
K: AsRef<[u8]>,
Returns true if the Tree contains a value for the specified key.
ⓘImportant traits for ExpiringIter<'a, V, E, F>pub fn iter<'a>(&'a self) -> ExpiringIter<'a, V, E, F>[src]
Create a double-ended iterator over the tuples of keys and values in this tree.
ⓘImportant traits for ExpiringIter<'a, V, E, F>pub fn range<'a, K, R>(&'a self, range: R) -> ExpiringIter<'a, V, E, F> where
K: AsRef<[u8]>,
R: RangeBounds<K>, [src]
K: AsRef<[u8]>,
R: RangeBounds<K>,
Create a double-ended iterator over tuples of keys and values, where the keys fall within the specified range.
pub fn get_lt<K>(&self, key: K) -> Result<Option<(IVec, V)>> where
K: AsRef<[u8]>, [src]
K: AsRef<[u8]>,
Retrieve the key and value before the provided key, if one exists.
pub fn get_gt<K>(&self, key: K) -> Result<Option<(IVec, V)>> where
K: AsRef<[u8]>, [src]
K: AsRef<[u8]>,
Retrieve the next key and value from the Tree after the provided key.
Note
The order follows the Ord implementation for Vec
[] < [0] < [255] < [255, 0] < [255, 255] ...
To retain the ordering of numerical types use big endian reprensentation
ⓘImportant traits for ExpiringIter<'a, V, E, F>pub fn scan_prefix<'a, P>(&'a self, prefix: P) -> ExpiringIter<'a, V, E, F> where
P: AsRef<[u8]>, [src]
P: AsRef<[u8]>,
Create an iterator over tuples of keys and values, where the all the keys starts with the given prefix.
pub fn pop_max(&self) -> Result<Option<(IVec, V)>>[src]
Atomically removes the maximum item in the Tree instance.
pub fn pop_min(&self) -> Result<Option<(IVec, V)>>[src]
Atomically removes the minimum item in the Tree instance.
pub fn len(&self) -> usize[src]
Returns the number of elements in this tree.
Beware: performs a full O(n) scan under the hood.
pub fn is_empty(&self) -> bool[src]
Returns true if the Tree contains no elements.
pub fn clear(&self) -> Result<()>[src]
Clears the Tree, removing all values.
Note that this is not atomic.
pub fn name(&self) -> String[src]
Returns the name of the tree.
pub fn expired<'a>(&'a self) -> impl 'a + Iterator<Item = IVec>[src]
Create an iterator over the keys of expired records
Trait Implementations
impl<V: Clone, E: Clone, F: Clone> Clone for ExpiringTree<V, E, F>[src]
fn clone(&self) -> ExpiringTree<V, E, F>[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
Auto Trait Implementations
impl<V, E, F> Send for ExpiringTree<V, E, F> where
E: Send,
F: Send,
V: Send,
E: Send,
F: Send,
V: Send,
impl<V, E, F> Unpin for ExpiringTree<V, E, F> where
E: Unpin,
F: Unpin,
V: Unpin,
E: Unpin,
F: Unpin,
V: Unpin,
impl<V, E, F> Sync for ExpiringTree<V, E, F> where
E: Sync,
F: Sync,
V: Sync,
E: Sync,
F: Sync,
V: Sync,
impl<V, E, F> !UnwindSafe for ExpiringTree<V, E, F>
impl<V, E, F> !RefUnwindSafe for ExpiringTree<V, E, F>
Blanket Implementations
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> From<T> for T[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,