Skip to content

PooledQueueCache Methods

The PooledQueueCache is a cache that is intended to serve as a message cache in an IQueueCache. It is capable of storing large numbers of messages (gigs worth of messages) for extended periods of time (minutes to indefinite), while incurring a minimal performance hit due to garbage collection. This pooled cache allocates memory and never releases it. It keeps freed resources available in pools that remain in application use through the life of the service. This means these objects go to gen2, are compacted, and then stay there. This is relatively cheap, as the only cost they now incur is the cost of checking to see if they should be freed in each collection cycle. Since this cache uses small numbers of large objects with relatively simple object graphs, they are less costly to check then large numbers of smaller objects with more complex object graphs. For performance reasons this cache is designed to more closely align with queue specific data. This is, in part, why, unlike the SimpleQueueCache, this cache does not implement IQueueCache. It is intended to be used in queue specific implementations of IQueueCache.

GetCursor(StreamId, StreamSequenceToken?)

View source
[System.Obsolete(Use TryGetCursor instead.)]
public object GetCursor(StreamId streamId, StreamSequenceToken? sequenceToken)
Acquires a cursor to enumerate through the messages in the cache at the provided sequenceToken, filtered on the specified stream.

Parameters

streamIdStreamId
stream identity
sequenceTokenStreamSequenceToken?

Returns

The acquired cache cursor.

Exceptions

Orleans.Streams.QueueCacheMissException
The requested token is older than the messages retained by the cache.

Refresh(object, StreamSequenceToken?)

View source
public void Refresh(object cursorObj, StreamSequenceToken? sequenceToken)
Repositions an idle or unset cursor at the provided sequence token.

Parameters

cursorObjobject
The cursor to refresh.
sequenceTokenStreamSequenceToken?
The sequence token to position the cursor at.

TryGetCursor(StreamId, StreamSequenceToken?)

View source
public QueueCacheCursorResult<object> TryGetCursor(StreamId streamId, StreamSequenceToken? sequenceToken)
Attempts to acquire a cursor at the provided sequence token.

Parameters

streamIdStreamId
The stream identifier.
sequenceTokenStreamSequenceToken?
The sequence token.

Returns

A successful result containing the acquired cursor, or a cache-miss result containing the unavailable position and current cache bounds.

TryGetCursorAtPosition(StreamId, StreamSubscriptionStartPosition)

View source
public QueueCacheCursorResult<object> TryGetCursorAtPosition(StreamId streamId, StreamSubscriptionStartPosition startPosition)
Attempts to acquire a cursor at the specified subscription start position.

Parameters

streamIdStreamId
The stream identifier.
startPositionStreamSubscriptionStartPosition
The initial subscription position.

Returns

A successful result containing the acquired cursor.

Exceptions

System.ArgumentOutOfRangeException
startPosition is not defined.

TryGetNextMessage(object, IBatchContainer?)

View source
[System.Obsolete(Use TryGetNextMessageWithResult instead.)]
public bool TryGetNextMessage(object cursorObj, out IBatchContainer? message)
Acquires the next message in the cache at the provided cursor

Parameters

cursorObjobject
messageIBatchContainer?

Returns

true when a message was returned; otherwise, false.

Exceptions

System.ArgumentNullException
cursorObj is null.
System.ArgumentOutOfRangeException
cursorObj is not a cache cursor.
Orleans.Streams.QueueCacheMissException
The cursor position is older than the messages retained by the cache.

TryGetNextMessageWithResult(object, IBatchContainer?)

View source
public QueueCacheCursorMoveResult TryGetNextMessageWithResult(object cursorObj, out IBatchContainer? message)
Attempts to acquire the next message in the cache at the provided cursor.

Parameters

cursorObjobject
The cache cursor.
messageIBatchContainer?
The next message when one is available.

Returns

A successful result with a non-null message, QueueCacheCursorMoveResultKind with a null message, or a cache-miss result with a null message.

Exceptions

System.ArgumentNullException
cursorObj is null.
System.ArgumentOutOfRangeException
cursorObj is not a cache cursor.