Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
languagejava
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
languagejava
queue.iterate(new RetrieveQueueItemsListener<MyRecord>() {
    @Override
    public void onItem(MyRecord record) {
        //....
    }
});

To remove all items from queue you can use clean method:

Code Block
languagejava
//remove all items and clean file
queue.clear();