mirror of https://github.com/tikv/client-rust.git
parent
80ec5defbb
commit
1098583d92
|
@ -5,7 +5,11 @@ use derive_new::new;
|
|||
use futures::stream::BoxStream;
|
||||
use std::ops::RangeBounds;
|
||||
|
||||
/// A readonly transaction which can have a custom timestamp.
|
||||
/// A read-only transaction which reads at the given timestamp.
|
||||
///
|
||||
/// It behaves as if the snapshot was taken at the given timestamp,
|
||||
/// i.e. it can read operations happened before the timestamp,
|
||||
/// but ignores operations after the timestamp.
|
||||
///
|
||||
/// See the [Transaction](struct@crate::Transaction) docs for more information on the methods.
|
||||
#[derive(new)]
|
||||
|
@ -14,12 +18,12 @@ pub struct Snapshot {
|
|||
}
|
||||
|
||||
impl Snapshot {
|
||||
/// Gets the value associated with the given key.
|
||||
/// Get the value associated with the given key.
|
||||
pub async fn get(&self, key: impl Into<Key>) -> Result<Option<Value>> {
|
||||
self.transaction.get(key).await
|
||||
}
|
||||
|
||||
/// Gets the values associated with the given keys.
|
||||
/// Get the values associated with the given keys.
|
||||
pub async fn batch_get(
|
||||
&self,
|
||||
keys: impl IntoIterator<Item = impl Into<Key>>,
|
||||
|
@ -27,6 +31,7 @@ impl Snapshot {
|
|||
self.transaction.batch_get(keys).await
|
||||
}
|
||||
|
||||
/// Scan a range, return at most `limit` key-value pairs that lying in the range.
|
||||
pub async fn scan(
|
||||
&self,
|
||||
range: impl Into<BoundRange>,
|
||||
|
@ -35,7 +40,8 @@ impl Snapshot {
|
|||
self.transaction.scan(range, limit).await
|
||||
}
|
||||
|
||||
pub fn scan_reverse(&self, range: impl RangeBounds<Key>) -> BoxStream<Result<KvPair>> {
|
||||
/// Unimplemented. Similar to scan, but in the reverse direction.
|
||||
fn scan_reverse(&self, range: impl RangeBounds<Key>) -> BoxStream<Result<KvPair>> {
|
||||
self.transaction.scan_reverse(range)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue