Expand description
§Persy - Transactional Persistence Engine
Simple single file durable, isolated, consistent, and atomic persistence engine based on copy on write. It guarantee the persistence of data even in case of crash through a in file write ahead log, and provide simple rust APIs for store simple bytes or value associated (index) data, provide also memory management logic to keep the file size in check.
§Example
use persy::{Persy,Config};
//...
Persy::create("./target/data.persy")?;
let persy = Persy::open("./target/data.persy",Config::new())?;
let mut tx = persy.begin()?;
tx.create_segment("seg")?;
let data = vec![1;20];
tx.insert("seg", &data)?;
let prepared = tx.prepare()?;
prepared.commit()?;
for (_id,content) in persy.scan("seg")? {
assert_eq!(content[0], 1);
//....
}
§Example Index
use persy::{Persy,Config, ValueMode};
//...
Persy::create("./target/index_data.persy")?;
let persy = Persy::open("./target/index_data.persy",Config::new())?;
let mut tx = persy.begin()?;
tx.create_index::<i32,i32>("index", ValueMode::Cluster)?;
tx.put("index", 10, 20)?;
let prepared = tx.prepare()?;
prepared.commit()?;
for (key,values) in persy.range::<i32,i32,_>("index", ..)? {
assert_eq!(key, 10);
assert_eq!(values.into_iter().collect::<Vec<_>>(), vec![20]);
//....
}
Modules§
Structs§
- ByteVec
- Wrapper for
Vec<u8>
for use it in index keys or values - Config
- Persy configuration structure.
- IndexId
- Unique identifier of an index
- Index
Info - Index definition details
- Index
Iter - Index Iterator implementation for iterating on a range of keys
- Open
Options - Options, flags, configs which can be used to configure how a persy database is opened.
- Persy
- Main structure to operate persy storage files
- PersyId
- Identifier of a persistent record, can be used for read, update or delete the record
- Recover
- Intermediate recover status to select witch transactions to commit or rollback and list witch transactions are in a intermediate state
- Segment
Id - Represents a looked-up segment
- Segment
Iter - Iterator implementation used to scan a segment
- Snapshot
- Read snapshot at a specific point in time.
- Snapshot
Segment Iter - Iterator implementation to scan a segment at the current snapshot state.
- Transaction
- Transaction container, it include all the changes done in a transaction.
- Transaction
Config - Configure the parameters for the transaction on the begin of a new transaction.
- Transaction
Finalize - prepared transaction state
- TxIndex
Iter - Index Iterator implementation for iterating on a range of keys considering changes in transaction
- TxSegment
Iter - Iterator implementation to scan a segment considering in transaction changes.
- Value
Iter - Iterator of values relative to an index key use by get and range functions
Enums§
- Begin
Transaction Error - Create
Error - Create
Index Error - Create
Segment Error - Delete
Error - Drop
Index Error - Drop
Segment Error - Generic
Error - Index
Change Error - Index
Error - Index
OpsError - Index
PutError - Index
Type Id - Enum of all the possible Key or Value types for indexes
- Insert
Error - Open
Error - Open
Memory Error - PE
- Wrapper enum for all the possible Persy errors,
- Persy
Error - Enum of all possible errors from Persy
- Prepare
Error - Read
Error - Recover
Status - Possible state of a transaction in the log
- Segment
Error - TxStrategy
- Concurrent Modification Strategy for resolution of conflict on commit.
- Update
Error - Value
Mode - Define the behavior of the index in case a key value pair already exists
Traits§
Type Aliases§
- Transaction
Id - Custom identifier to track the transaction in the recover phase