Beispiel #1
0
  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();
  }
Beispiel #2
0
 public long incrementQuotaUsage(String username, long increment) {
   long val = db.getAtomicLong(username).addAndGet(increment);
   db.commit();
   return val;
 }
Beispiel #3
0
  public long getQuotaUsage(String username) {
    if (!db.exists(username)) db.createAtomicLong(username, 0);

    return db.getAtomicLong(username).get();
  }
Beispiel #4
0
 /** default constructed initializes to zero */
 public void testConstructor2() {
   Atomic.Long ai = db.getAtomicLong("test2");
   assertEquals(0, ai.get());
 }