public class InMemoryQueuePersistor<T> extends 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(Long idx)
Return the item with the given id.
|
boolean |
hasNext()
Are there more items waiting to be returned?
|
Iterator<T> |
iterator() |
long |
lastId()
Get the value of the last item to have been persisted.
|
Long |
offer(T obj)
Persist and return the last Long id of the item.
|
Long |
offerAll(Collection<T> t)
Persist N items in batch and return a Long id of the last item.
|
Map<Long,T> |
refMap() |
T |
remove()
Remove the oldest item from the persistence queue.
|
long |
size()
Get the number of items persisted right now.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
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 Long offer(@Nonnull T obj)
QueuePersistor
offer
in interface QueuePersistor<T>
obj
- element to persistpublic Long offerAll(@Nonnull Collection<T> t)
QueuePersistor
offerAll
in interface QueuePersistor<T>
t
- element to persistpublic T get(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>
Copyright © 2017. All rights reserved.