Skip to content

CachedMessageBlock Methods

CachedMessageBlock is a block of tightly packed structures containing tracking data for cached messages. This data is tightly packed to reduced GC pressure. The tracking data is used by the queue cache to walk the cache serving ordered queue messages by stream.

Add(CachedMessage)

View source
public void Add(CachedMessage message)
Add a message from the queue to the block. Converts the queue message to a cached message and stores it at the end of the block.

Parameters

messageCachedMessage
The message to add to this block.

GetIndexOfFirstMessageLessThanOrEqualTo(StreamSequenceToken)

View source
public int GetIndexOfFirstMessageLessThanOrEqualTo(StreamSequenceToken token)
Gets the index of the first message in this block that has a sequence token at or before the provided token

Parameters

tokenStreamSequenceToken
The sequence token.

Returns

The index of the first message in this block that has a sequence token equal to or before the provided token.

GetNewestSequenceToken(ICacheDataAdapter)

View source
public StreamSequenceToken GetNewestSequenceToken(ICacheDataAdapter dataAdapter)
Gets the sequence token of the newest message in this block

Parameters

dataAdapterICacheDataAdapter
The data adapter.

Returns

The sequence token of the newest message in this block.

GetOldestSequenceToken(ICacheDataAdapter)

View source
public StreamSequenceToken GetOldestSequenceToken(ICacheDataAdapter dataAdapter)
Gets the sequence token of the oldest message in this block

Parameters

dataAdapterICacheDataAdapter
The data adapter.

Returns

The sequence token of the oldest message in this block.

GetSequenceToken(int, ICacheDataAdapter)

View source
public StreamSequenceToken GetSequenceToken(int index, ICacheDataAdapter dataAdapter)
Gets the sequence token of the cached message a the provided index

Parameters

indexint
The index of the message to access.
dataAdapterICacheDataAdapter
The data adapter.

Returns

The sequence token.

OnResetState

override
View source
public override void OnResetState()
Notifies the object that it has been purged, so it can reset itself to the state of a newly allocated object.

Remove

View source
public bool Remove()
Removes a message from the start of the block (oldest data).

Returns

true if there are more items remaining; otherwise false.

TryFindFirstMessage(StreamId, ICacheDataAdapter, int)

View source
public bool TryFindFirstMessage(StreamId streamId, ICacheDataAdapter dataAdapter, out int index)
Tries to find the first message in the block that is part of the provided stream.

Parameters

streamIdStreamId
The stream identifier.
dataAdapterICacheDataAdapter
The data adapter.
indexint
The index.

Returns

true if the message was found, false otherwise.

TryFindNextMessage(int, StreamId, ICacheDataAdapter, int)

View source
public bool TryFindNextMessage(int start, StreamId streamId, ICacheDataAdapter dataAdapter, out int index)
Tries to get the next message from the provided stream, starting at the start index.

Parameters

startint
The start index.
streamIdStreamId
The stream identifier.
dataAdapterICacheDataAdapter
The data adapter.
indexint
The index.

Returns

true if the message was found, false otherwise.