Fix Bug #54 - Update the example about reading the uncommited writes

without.crypto
Andrei Oprea 6 years ago
parent eda3295fff
commit 08f12b3155
  1. 14
      examples/simple-store.rs
  2. 10
      src/lib.rs

@ -77,6 +77,20 @@ fn main() {
println!("Get non-existent {:?}", r.get("non-existent").unwrap());
}
println!("Looking up keys via Writer.get()...");
{
let mut writer = store.write(&k).unwrap();
writer.put("foo", &Value::Str("bar")).unwrap();
writer.put("bar", &Value::Str("baz")).unwrap();
writer.delete("foo").unwrap();
println!("It should be None! ({:?})", writer.get("foo").unwrap());
println!("Get bar ({:?})", writer.get("bar").unwrap());
writer.commit().unwrap();
let reader = store.read(&k).expect("reader");
println!("It should be None! ({:?})", reader.get("foo").unwrap());
println!("Get bar {:?}", reader.get("bar").unwrap());
}
println!("Aborting transaction...");
{
// Aborting a write transaction rollbacks the change(s)

@ -146,13 +146,13 @@
//! writer.put("bar", &Value::Str("baz")).unwrap();
//! writer.delete("foo").unwrap();
//!
//! // A write transaction also supports reading, but the version
//! // of the store that it reads doesn't include changes it has made.
//! // A write transaction also supports reading, the version of the
//! // store that it reads includes changes it has made regardless of
//! // the commit state of that transaction.
//! // In the code above, "foo" and "bar" were put into the store,
//! // then "foo" was deleted; but neither key is visible to readers,
//! // not even to the writer itself, until the transaction is committed.
//! // then "foo" was deleted so only "bar" will return a result.
//! println!("It should be None! ({:?})", writer.get("foo").unwrap());
//! println!("It should be None! ({:?})", writer.get("bar").unwrap());
//! println!("Get bar ({:?})", writer.get("bar").unwrap());
//! writer.commit().unwrap();
//! let reader = store.read(&env).expect("reader");
//! println!("It should be None! ({:?})", reader.get("foo").unwrap());

Loading…
Cancel
Save