public static void main(String[] args) throws Exception { CacheTable t = new CacheTable().setDefaultKeepTime(1000).setMaxRow(100); for (int i = 0; i < 100; i++) { // if (i % 5 == 0) { // t.put(i, i, 10000); // } else { t.put(i, i); // } } Enumeration e = t.keys(); System.out.println(t.get(0)); System.out.println(t.get(10)); System.out.println(t.get(99)); Thread.sleep(2000); // t.clearExpiredItems(); System.out.println("----->" + t.size()); System.out.println(t.getFirstValue()); }
public Block getReadBlock(String date, int blockNum) { Block b = readCache.get(new BKey(date, blockNum)); if (b != null) return b; File f = getFile(date, blockNum); if (f.exists() == false) return null; try { byte[] gz = FileUtil.readAll(f); gz = CompressUtil.unZip(gz); Block bk = new Block(date, gz, 0, gz.length, GZipCtr.BLOCK_MAX_SIZE); bk.blockNum = blockNum; readCache.put(new BKey(date, blockNum), bk, conf._compress_read_cache_expired_ms); return bk; } catch (Throwable e) { e.printStackTrace(); } return null; } public void shutdown() {
public static void main(String[] args) throws Exception { CacheTable t = new CacheTable().setDefaultKeepTime(1000).setMaxRow(100); for (int i = 0; i < 100; i++) { // if (i % 5 == 0) { // t.put(i, i, 10000); // } else { t.put(i, i); // } } Enumeration e = t.keys(); System.out.println(t.get(0)); System.out.println(t.get(10)); System.out.println(t.get(99)); Thread.sleep(2000); // t.clearExpiredItems(); System.out.println("----->" + t.size()); System.out.println(t.getFirstValue()); }
private void addCounter0(AddCounterParam param) { ObjectType objectType = param.objectType; Counter counter = param.counter; Logger.println("[counter+]Trying to add new counter : " + objectType.getFamily().getName() + " - " + counter.getName()); //TODO login check if (counter.semanticEquals(prevAddedCounter.get(counter.getName()))) { Logger.println("[counter+] ignored by equals"); return; } Family family = objectType.getFamily(); family.addCounter(counter); boolean success = counterManager.safelyAddFamily(family); if (success) { prevAddedCounter.put(counter.getName(), counter); changeNotifyQueue.put(1); } } }
public static void main(String[] args) throws Exception { CacheTable t = new CacheTable().setDefaultKeepTime(1000).setMaxRow(100); for (int i = 0; i < 100; i++) { // if (i % 5 == 0) { // t.put(i, i, 10000); // } else { t.put(i, i); // } } Enumeration e = t.keys(); System.out.println(t.get(0)); System.out.println(t.get(10)); System.out.println(t.get(99)); Thread.sleep(2000); // t.clearExpiredItems(); System.out.println("----->" + t.size()); System.out.println(t.getFirstValue()); }
public Block getReadBlock(String date, int blockNum) { Block b = readCache.get(new BKey(date, blockNum)); if (b != null) return b; File f = getFile(date, blockNum); if (f.exists() == false) return null; try { byte[] gz = FileUtil.readAll(f); gz = CompressUtil.unZip(gz); Block bk = new Block(date, gz, 0, gz.length, GZipCtr.BLOCK_MAX_SIZE); bk.blockNum = blockNum; readCache.put(new BKey(date, blockNum), bk, conf._compress_read_cache_expired_ms); return bk; } catch (Throwable e) { e.printStackTrace(); } return null; } public void shutdown() {
public static void main(String[] args) throws Exception { CacheTable t = new CacheTable().setDefaultKeepTime(1000).setMaxRow(100); for (int i = 0; i < 100; i++) { // if (i % 5 == 0) { // t.put(i, i, 10000); // } else { t.put(i, i); // } } Enumeration e = t.keys(); System.out.println(t.get(0)); System.out.println(t.get(10)); System.out.println(t.get(99)); Thread.sleep(2000); // t.clearExpiredItems(); System.out.println("----->" + t.size()); System.out.println(t.getFirstValue()); }
private void addCounter0(AddCounterParam param) { ObjectType objectType = param.objectType; Counter counter = param.counter; Logger.println("[counter+]Trying to add new counter : " + objectType.getFamily().getName() + " - " + counter.getName()); //TODO login check if (counter.semanticEquals(prevAddedCounter.get(counter.getName()))) { Logger.println("[counter+] ignored by equals"); return; } Family family = objectType.getFamily(); family.addCounter(counter); boolean success = counterManager.safelyAddFamily(family); if (success) { prevAddedCounter.put(counter.getName(), counter); changeNotifyQueue.put(1); } } }
public static void main(String[] args) throws Exception { CacheTable t = new CacheTable().setDefaultKeepTime(1000).setMaxRow(100); for (int i = 0; i < 100; i++) { // if (i % 5 == 0) { // t.put(i, i, 10000); // } else { t.put(i, i); // } } Enumeration e = t.keys(); System.out.println(t.get(0)); System.out.println(t.get(10)); System.out.println(t.get(99)); Thread.sleep(2000); // t.clearExpiredItems(); System.out.println("----->" + t.size()); System.out.println(t.getFirstValue()); }
public static void main(String[] args) throws Exception { CacheTable t = new CacheTable().setDefaultKeepTime(1000).setMaxRow(100); for (int i = 0; i < 100; i++) { // if (i % 5 == 0) { // t.put(i, i, 10000); // } else { t.put(i, i); // } } Enumeration e = t.keys(); System.out.println(t.get(0)); System.out.println(t.get(10)); System.out.println(t.get(99)); Thread.sleep(2000); // t.clearExpiredItems(); System.out.println("----->" + t.size()); System.out.println(t.getFirstValue()); }
public static void main(String[] args) throws Exception { CacheTable t = new CacheTable().setDefaultKeepTime(1000).setMaxRow(100); for (int i = 0; i < 100; i++) { // if (i % 5 == 0) { // t.put(i, i, 10000); // } else { t.put(i, i); // } } Enumeration e = t.keys(); System.out.println(t.get(0)); System.out.println(t.get(10)); System.out.println(t.get(99)); Thread.sleep(2000); // t.clearExpiredItems(); System.out.println("----->" + t.size()); System.out.println(t.getFirstValue()); }
public static void main(String[] args) throws Exception { CacheTable t = new CacheTable().setDefaultKeepTime(1000).setMaxRow(100); for (int i = 0; i < 100; i++) { // if (i % 5 == 0) { // t.put(i, i, 10000); // } else { t.put(i, i); // } } Enumeration e = t.keys(); System.out.println(t.get(0)); System.out.println(t.get(10)); System.out.println(t.get(99)); Thread.sleep(2000); // t.clearExpiredItems(); System.out.println("----->" + t.size()); System.out.println(t.getFirstValue()); }