| IRingbufferTAdd Method |
Adds an item to the tail of the Ringbuffer.
Namespace:
Hazelcast.Core
Assembly:
Hazelcast.Net (in Hazelcast.Net.dll) Version: 3.12.2
Syntax Function Add (
item As T
) As Long
abstract Add :
item : 'T -> int64
Parameters
- item
- Type: T
the item to add.
Return Value
Type:
Int64the sequence of the added item.
Exceptions Exception | Condition |
---|
ArgumentNullException | if item is null. |
Remarks
Adds an item to the tail of the Ringbuffer. If there is no space in the Ringbuffer, the add will overwrite the oldest
item in the ringbuffer no matter what the ttl is. For more control on this behavior, check the
AddAsync(T, OverflowPolicy)
and the
OverflowPolicy
.
The returned value is the sequence of the added item. Using this sequence you can read the added item.
Using the sequence as id
This sequence will always be unique for this Ringbuffer instance so it can be used as a unique id generator if you are
publishing items on this Ringbuffer. However you need to take care of correctly determining an initial id when any node
uses the ringbuffer for the first time. The most reliable way to do that is to write a dummy item into the ringbuffer and
use the returned sequence as initial id. On the reading side, this dummy item should be discard. Please keep in mind that
this id is not the sequence of the item you are about to publish but from a previously published item. So it can't be used
to find that item.
See Also