Alien-Libjio

 view release on metacpan or  search on metacpan

libjio/doc/guide.rst  view on Meta::CPAN

open file, just like a regular file descriptor or a *FILE **.

Then second is *jtrans_t*, usually called the transaction structure, which
represents a single transaction.


Basic operation
---------------

First of all, as with regular I/O, you need to open your files. This is done
with *jopen()*, which looks a lot like *open()* but returns a file structure
instead of a file descriptor (this will be very common among all the
functions), and adds a new parameter *jflags* that can be used to modify some
library behaviour we'll see later, and is normally not used.

Now that you have opened a file, the next thing to do would be to create a
transaction. This is what *jtrans_new()* is for: it takes a file structure and
returns a new transaction structure.

To add a write operation to the transaction, use *jtrans_add_w()*. You can add
as many operations as you want. Operations within a transaction may overlap,

libjio/doc/libjio.rst  view on Meta::CPAN

 - Lock the file offsets where the commit takes place
 - Open the transaction file
 - Write the header
 - Read all the previous data from the file
 - Write the previous data in the transaction
 - Write the data to the file
 - Mark the transaction as committed by setting a flag in the header
 - Unlink the transaction file
 - Unlock the offsets where the commit takes place

This may seem like a lot of steps, but they're not as much as it looks like
inside the code, and allows a recovery from interruptions in every step of the
way, and even in the middle of a step.


The rollback procedure
----------------------

First of all, rollbacking is like "undo" a commit: returns the data to the
state it had exactly before a given commit was applied. Due to the way we
handle commits, doing this operation becomes quite simple and straightforward.



( run in 0.498 second using v1.01-cache-2.11-cpan-64827b87656 )