2011-05-29 13:25:25 +02:00
|
|
|
package com.Acrobot.ChestShop.DB;
|
|
|
|
|
|
|
|
import com.Acrobot.ChestShop.ChestShop;
|
2011-06-09 22:54:01 +02:00
|
|
|
import com.Acrobot.ChestShop.Config.Config;
|
2011-06-11 17:36:55 +02:00
|
|
|
import com.Acrobot.ChestShop.Config.Property;
|
2011-05-29 13:25:25 +02:00
|
|
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Acrobot
|
|
|
|
*/
|
|
|
|
public class Queue implements Runnable {
|
2011-07-23 21:00:47 +02:00
|
|
|
private static final List<Transaction> queue = new LinkedList<Transaction>();
|
2011-05-29 13:25:25 +02:00
|
|
|
|
2011-06-09 22:54:01 +02:00
|
|
|
public static void addToQueue(Transaction t) {
|
2011-05-29 13:25:25 +02:00
|
|
|
queue.add(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void run() {
|
2011-06-11 17:36:55 +02:00
|
|
|
List<Transaction> toDelete = ChestShop.getDB().find(Transaction.class).where().lt("sec", System.currentTimeMillis() / 1000 - Config.getInteger(Property.RECORD_TIME_TO_LIVE)).findList();
|
2011-05-29 13:25:25 +02:00
|
|
|
ChestShop.getDB().delete(toDelete);
|
|
|
|
ChestShop.getDB().save(queue);
|
|
|
|
queue.clear();
|
|
|
|
}
|
|
|
|
}
|