All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clickntap.tool.cache.MemoryCacheManager Maven / Gradle / Ivy

There is a newer version: 1.189
Show newest version
package com.clickntap.tool.cache;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class MemoryCacheManager implements CacheManager {

  private HashMap caches;

  public MemoryCacheManager() {
    caches = new HashMap();
  }

  public Cache getCache(String cacheName, int maxSize) throws Exception {
    synchronized (caches) {
      if (!caches.containsKey(cacheName))
        caches.put(cacheName, new MemoryCache());
      return caches.get(cacheName);
    }
  }

  public boolean containsCache(String cacheName) {
    return true;
  }

  public void reset() {
    synchronized (caches) {
      caches = new HashMap();
    }
  }

  public List getCacheNames() throws Exception {
    synchronized (caches) {
      List names = new ArrayList();
      names.addAll(caches.keySet());
      return names;
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy