Exemplo n.º 1
0
 public static byte[] retrieve(String key) {
   Pointer ptr = get(key);
   if (ptr == null) return null;
   if (ptr.expired() || ptr.free) {
     map.remove(key);
     if (!ptr.free) {
       MemoryManager.free(ptr);
     }
     return null;
   } else {
     return MemoryManager.retrieve(ptr);
   }
 }
Exemplo n.º 2
0
  public static void init(
      int numberOfBuffers, int size, int initialCapacity, int concurrencyLevel) {
    map =
        new MapMaker()
            .concurrencyLevel(concurrencyLevel)
            .initialCapacity(initialCapacity)
            .makeMap();

    logger.info("*** initializing *******************************\r\n" + Format.logo());
    logger.info("************************************************");
    MemoryManager.init(numberOfBuffers, size);
    logger.info("initialized");
    logger.info(
        Format.it("number of buffer(s): \t%1d  with %2s each", numberOfBuffers, Ram.inMb(size)));
    logger.info(Format.it("initial capacity: \t%1d", initialCapacity));
    logger.info(Format.it("concurrency level: \t%1d", concurrencyLevel));
  }
Exemplo n.º 3
0
 public static void collectLFU() {
   MemoryManager.collectLFU();
 }
Exemplo n.º 4
0
 public static void collectExpired() {
   MemoryManager.collectExpired();
 }
Exemplo n.º 5
0
 public static void free(String key) {
   Pointer p = map.remove(key);
   if (p != null) {
     MemoryManager.free(p);
   }
 }
Exemplo n.º 6
0
 public static Pointer update(String key, byte[] payload) {
   Pointer p = map.get(key);
   p = MemoryManager.update(p, payload);
   return p;
 }
Exemplo n.º 7
0
 public static Pointer put(String key, byte[] payload, int expiresIn) {
   return map.put(key, MemoryManager.store(payload, expiresIn));
 }
Exemplo n.º 8
0
 public static void clear() {
   map.clear();
   MemoryManager.clear();
   logger.info("Cache cleared");
 }