pub struct DBWithTTL { /* private fields */ }
Expand description
DB with ttl support wrapper
TTL is accepted in seconds If TTL is non positive or not provided, the behaviour is TTL = infinity (int32_t)Timestamp(creation) is suffixed to values in Put internally Expired TTL values are deleted in compaction only:(Timestamp+ttl<time_now) Get/Iterator may return expired entries(compaction not run on them yet) Different TTL may be used during different Opens Example: Open1 at t=0 with ttl=4 and insert k1,k2, close at t=2. Open2 at t=3 with ttl=5. Now k1,k2 should be deleted at t>=5 read_only=true opens in the usual read-only mode. Compactions will not be triggered(neither manual nor automatic), so no expired entries removed
Implementations§
Source§impl DBWithTTL
impl DBWithTTL
Sourcepub fn open_cf<P, I, N>(path: P, cf_names: I, ttl: i32) -> Result<Self>
pub fn open_cf<P, I, N>(path: P, cf_names: I, ttl: i32) -> Result<Self>
Open a database with ttl support.
Sourcepub fn get_pinned(
&self,
col: &str,
key: &[u8],
) -> Result<Option<DBPinnableSlice<'_>>>
pub fn get_pinned( &self, col: &str, key: &[u8], ) -> Result<Option<DBPinnableSlice<'_>>>
Return the value associated with a key using RocksDB’s PinnableSlice from the given column so as to avoid unnecessary memory copy.
Sourcepub fn put<K, V>(&self, col: &str, key: K, value: V) -> Result<()>
pub fn put<K, V>(&self, col: &str, key: K, value: V) -> Result<()>
Insert a value into the database under the given key.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DBWithTTL
impl RefUnwindSafe for DBWithTTL
impl Send for DBWithTTL
impl Sync for DBWithTTL
impl Unpin for DBWithTTL
impl UnwindSafe for DBWithTTL
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more