public void testTX() { TxMaker txMaker = DBMaker.newMemoryDB().makeTxMaker(); DB db = txMaker.makeTx(); System.out.println(db.getAtomicLong("counter").incrementAndGet()); db.commit(); db = txMaker.makeTx(); System.out.println(db.getAtomicLong("counter").incrementAndGet()); db.commit(); db = txMaker.makeTx(); System.out.println(db.getAtomicLong("counter").incrementAndGet()); db.commit(); }
public long incrementQuotaUsage(String username, long increment) { long val = db.getAtomicLong(username).addAndGet(increment); db.commit(); return val; }
public long getQuotaUsage(String username) { if (!db.exists(username)) db.createAtomicLong(username, 0); return db.getAtomicLong(username).get(); }
/** default constructed initializes to zero */ public void testConstructor2() { Atomic.Long ai = db.getAtomicLong("test2"); assertEquals(0, ai.get()); }