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§
source§impl 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.