public class InMemoryQueuePersistor<T> extends java.lang.Object implements QueuePersistor<T>
QueuePersistor
implementations that stores items in-memory.Constructor and Description |
---|
InMemoryQueuePersistor() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Release any internal resources used by the persistence mechanism.
|
T |
get(java.lang.Long idx)
Return the item with the given id.
|
boolean |
hasNext()
Are there more items waiting to be returned?
|
java.util.Iterator<T> |
iterator() |
long |
lastId()
Get the value of the last item to have been persisted.
|
java.lang.Long |
offer(T obj)
Persist and return the last Long id of the item.
|
java.lang.Long |
offerAll(java.util.Collection<T> t)
Persist N items in batch and return a Long id of the last item.
|
java.util.Map<java.lang.Long,T> |
refMap() |
T |
remove()
Remove the oldest item from the persistence queue.
|
long |
size()
Get the number of items persisted right now.
|
public long lastId()
QueuePersistor
lastId
in interface QueuePersistor<T>
public long size()
QueuePersistor
size
in interface QueuePersistor<T>
public boolean hasNext()
QueuePersistor
hasNext
in interface QueuePersistor<T>
true
if items can be retrieved from this persistor, false
otherwisepublic java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T>
public java.lang.Long offer(@Nonnull T obj)
QueuePersistor
offer
in interface QueuePersistor<T>
obj
- element to persistpublic java.lang.Long offerAll(@Nonnull java.util.Collection<T> t)
QueuePersistor
offerAll
in interface QueuePersistor<T>
t
- element to persistpublic T get(java.lang.Long idx)
QueuePersistor
get
in interface QueuePersistor<T>
idx
- the given index to lookuppublic T remove()
QueuePersistor
remove
in interface QueuePersistor<T>
public void close()
QueuePersistor
close
in interface QueuePersistor<T>
public java.util.Map<java.lang.Long,T> refMap()