bigqueue
bigqueue copied to clipboard
How to clear consumed items in order to reduce data on disk ?
I create a bigqueue, and enqueue many items, then dequeue all. But the size of bigqueue on disk will become bigger and bigger.
String queueDir = "/Users/ym/data/bigqueue";
String queueName = "demo";
IBigQueue bigQueue = null;
try {
bigQueue = new BigQueueImpl(queueDir, queueName);
for (int i = 0; i < 1000000; i++) {
String item = String.valueOf(i);
bigQueue.enqueue(item.getBytes());
}
// dequeue some items
for (int i = 0; i < 1000000; i++) {
String item = new String(bigQueue.dequeue());
System.out.println(item);
}
} finally {
bigQueue.close();
}
How to release space or reduce file ?
I have tried IBigQueue.gc() , but not working . IBigQueue.removeAll() will reduce the file, but I only want to clear consumed items.
@yanggeorge Which version of Java are you using? If you are using Java 11, it might be happening because of the issue mentioned here [https://github.com/bulldog2011/bigqueue/issues/39]