void Run() { while (running) { DBID firstDB = 0, lastDB = 0; if (0 == adb->LastDB(lastDB) && 0 == adb->FirstDB(firstDB)) { for (DBID db = firstDB; db <= lastDB; db++) { DBID nexdb = db; if (adb->DBExist(db, nexdb)) { adb->CheckExpireKey(db); } else { if (nexdb == db) { break; } adb->CheckExpireKey(nexdb); db = nexdb; } } } uint64 end = get_current_epoch_micros(); uint64 sleep = check_period; if (adb->m_min_expireat > end) { sleep = (adb->m_min_expireat - end) / 1000; if (sleep > check_period) { sleep = check_period; } if (sleep == 0) { sleep = 1; } } Thread::Sleep(sleep); } }
void test_zset_expire(Ardb& db) { DBID dbid = 0; db.ZClear(dbid, "myzset"); db.ZAdd(dbid, "myzset", ValueData((int64) 1), "one"); db.Expire(dbid, "myzset", 1); CHECK_FATAL(db.Exists(dbid, "myzset") == false, "Expire myzset failed"); sleep(2); db.CheckExpireKey(dbid, 50, 10000); CHECK_FATAL(db.Exists(dbid, "myzset") == true, "Expire myzset failed"); }
void Run() { while (running) { DBID dbid = 0; while (dbid < ARDB_GLOBAL_DB) { DBID nexdb = 0; if (adb->DBExist(dbid, nexdb)) { adb->CheckExpireKey(dbid); dbid++; } else { if (nexdb == dbid || nexdb == ARDB_GLOBAL_DB) { break; } adb->CheckExpireKey(nexdb); dbid = nexdb + 1; } } uint64 end = get_current_epoch_micros(); uint64 sleep = check_period; if (adb->m_min_expireat > end) { sleep = (adb->m_min_expireat - end) / 1000; if (sleep > check_period) { sleep = check_period; } if (sleep == 0) { sleep = 1; } } Thread::Sleep(sleep); } }