Esempio 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);
   }
 }
Esempio 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));
  }
Esempio n. 3
0
 public static void collectLFU() {
   MemoryManager.collectLFU();
 }
Esempio n. 4
0
 public static void collectExpired() {
   MemoryManager.collectExpired();
 }
Esempio n. 5
0
 public static void free(String key) {
   Pointer p = map.remove(key);
   if (p != null) {
     MemoryManager.free(p);
   }
 }
Esempio n. 6
0
 public static Pointer update(String key, byte[] payload) {
   Pointer p = map.get(key);
   p = MemoryManager.update(p, payload);
   return p;
 }
Esempio n. 7
0
 public static Pointer put(String key, byte[] payload, int expiresIn) {
   return map.put(key, MemoryManager.store(payload, expiresIn));
 }
Esempio n. 8
0
 public static void clear() {
   map.clear();
   MemoryManager.clear();
   logger.info("Cache cleared");
 }