@Override
 public void delete(String ref) {
   // TODO Auto-generated method stub
   if (cache.isKeyInCache(ref)) {
     cache.remove(ref);
   }
 }
 @Override
 public Client get(String ref) {
   // TODO Auto-generated method stub
   Client client = null;
   if (cache.isKeyInCache(ref)) {
     Element elem = cache.get(ref);
     client = (Client) elem.getObjectValue();
   }
   return client;
 }
 @Override
 public void update(Client entity) {
   // TODO Auto-generated method stub
   if (cache != null) {
     if (cache.isKeyInCache(entity.getEmail())) {
       cache.acquireWriteLockOnKey(entity.getEmail());
       cache.remove(entity.getEmail());
       cache.put(new Element(entity.getEmail(), entity));
       cache.releaseWriteLockOnKey(entity.getEmail());
     } else cache.put(new Element(entity.getEmail(), entity));
   }
 }
Beispiel #4
0
 @SuppressWarnings("unchecked")
 public <T> T get(String url, Class<T> clazz, MediaType mediaType) {
   Serializable cacheKey = key(url, clazz, mediaType);
   if (cache.isKeyInCache(cacheKey)) {
     Element element = cache.get(cacheKey);
     if (element != null) {
       Object objectValue = element.getObjectValue();
       return (T) objectValue;
     }
   }
   return null;
 }
Beispiel #5
0
  @SuppressWarnings("unchecked")
  public C getCached() {
    if (query.isCacheable()) {
      Cache cache = ccf.get(query);
      if (cache == null) {

        if (log.isDebugEnabled()) {
          log.debug(String.format("Cache for %s not found", this));
        }

      } else {

        if (log.isDebugEnabled()) {
          log.debug(String.format("Cache for %s found", this));
        }

        if (cache.isKeyInCache(getId())) {

          Element el = cache.get(getId());
          boolean expired = (el == null || el.isExpired());

          if (log.isDebugEnabled()) {

            log.debug(
                String.format(
                    "Element %d found in %s cache (expired = %s)",
                    getId(), query.getQid(), expired));
          }

          if (el != null && !expired) {
            return (C) el.getObjectValue();
          }

        } else {

          if (log.isDebugEnabled()) {
            log.debug(String.format("Element %d not found in %s cache", getId(), query.getQid()));
          }
        }
      }
    }

    return (C) null;
  }
Beispiel #6
0
  public CacheStats getCacheStats() {
    CacheStats cs = new CacheStats();

    if (query.isCacheable()) {
      Cache cache = ccf.get(query);
      if (cache != null) {
        if (cache.isKeyInCache(getId())) {
          Element el = cache.get(getId());
          cs.setExpired(el == null || el.isExpired());

          if (el != null && !cs.isExpired()) {
            cs.setLastUpdate(el.getLastUpdateTime());
            cs.setExpTime(el.getExpirationTime());
            cs.setHitCount(el.getHitCount());
          }
        }
      }
    }
    return cs;
  }
 public boolean hasKey(Object key) {
   return ehcache.isKeyInCache(key);
 }
Beispiel #8
0
 public boolean contains(String itemLink) {
   return cache.isKeyInCache(itemLink);
 }
Beispiel #9
0
 @Override
 public boolean containsBO(String hash) {
   boolean flag = cache.isKeyInCache(hash);
   LOG.info("(PeersideCache ) BO already in cache: " + flag);
   return cache.isKeyInCache(hash);
 }
 public boolean isKeyInCache(Object o) {
   return cache.isKeyInCache(o);
 }