The function refetch/3 checks if an entry has been written since the
point in time represented by the given snapshot. If not, it returns
:unchanged, otherwise it fetches the entry from the transaction.
The check if the entry was written is performed without reading the
whole entry from disk, and instead only looking at index pages.
This function can be useful to implement optimistic concurrency control,
when one computes the update to an entry outside of a transaction to
avoid blocking writers, then opens a transaction and checks if the value
changed in the meanwhile (and if so, recomputes the update). In these
cases, using refetch/3 can improve performance, especially when the
value is large, by avoiding to read the value from disk if CubDB can
determine that it was not written by looking just at the index pages.
The function
refetch/3
checks if an entry has been written since the point in time represented by the given snapshot. If not, it returns:unchanged
, otherwise it fetches the entry from the transaction.The check if the entry was written is performed without reading the whole entry from disk, and instead only looking at index pages.
This function can be useful to implement optimistic concurrency control, when one computes the update to an entry outside of a transaction to avoid blocking writers, then opens a transaction and checks if the value changed in the meanwhile (and if so, recomputes the update). In these cases, using
refetch/3
can improve performance, especially when the value is large, by avoiding to read the value from disk ifCubDB
can determine that it was not written by looking just at the index pages.