...
Default PersistentSequence
implementation is optimized for writing data and reading operations may take a bit more time.
PersistentQueue
PersistentQueue
works like a queue but persist all items to disk. Thus it can restore its state after application restart. PersistentQueue
has similar to java.util.Queue methods:
Code Block |
---|
|
final PersistentQueue<MyRecord> queue = factory.buildQueue("queue_sample", serializer);
//push item to the tail of queue
queue.add(record);
// read iem from head but doesn't remove
record = queue.peek();
// extract item from head and remove it from queue
record = queue.poll(); |
Also PersistentQueue
allow to iterate all its items:
Code Block |
---|
|
queue.iterate(new RetrieveQueueItemsListener<MyRecord>() {
@Override
public void onItem(MyRecord record) {
//....
}
}); |
To remove all items from queue you can use clean method:
Code Block |
---|
|
//remove all items and clean file
queue.clear(); |