Struct ckb_db::db_with_ttl::DBWithTTL
source · [−]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
sourceimpl DBWithTTL
impl DBWithTTL
sourcepub fn open_cf<P, I, N>(path: P, cf_names: I, ttl: i32) -> Result<Self> where
P: AsRef<Path>,
I: IntoIterator<Item = N>,
N: Into<String>,
pub fn open_cf<P, I, N>(path: P, cf_names: I, ttl: i32) -> Result<Self> where
P: AsRef<Path>,
I: IntoIterator<Item = N>,
N: Into<String>,
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<()> where
K: AsRef<[u8]>,
V: AsRef<[u8]>,
pub fn put<K, V>(&self, col: &str, key: K, value: V) -> Result<()> where
K: AsRef<[u8]>,
V: AsRef<[u8]>,
Insert a value into the database under the given key.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for DBWithTTL
impl Send for DBWithTTL
impl Sync for DBWithTTL
impl Unpin for DBWithTTL
impl UnwindSafe for DBWithTTL
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more