Skip to content

How to fetch the last saved value? #610

Answered by badrishc
AntyaDev asked this question in Q&A
Discussion options

You must be logged in to vote

How to fetch the last saved value?

I assume you are talking about FasterLog and want to get the last committed value. FasterLog is committed until log.CommitedUntilAddress. One option is to scan that last committed page and find the last committed record.

var PageSize = 1L << logSettings.PageSizeBits;
var committedUntilAddress = log.CommittedUntilAddress;
var committedPageStart = committedUntilAddress & ~(PageSize - 1);
if (committedPageStart == committedUntilAddress) // corner case: committed until page boundary
   committedPageStart -= PageSize;

using (var iter = log.Scan(committedPageStart, committedUntilAddress))
{
   // skip to the last record of this scan
}

Does FASTER support s…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@AntyaDev
Comment options

Answer selected by AntyaDev
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants