/**
   * Method to remove the user profile from cache.
   *
   * @param userId
   */
  protected void removeProfileDataFromCache(String userId) throws ProfileServiceException {
    if (logger.isLoggable(Level.FINEST)) {
      logger.entering(sourceClass, "removeProfileDataFromCache", userId);
    }
    if (isEmail(userId)) {
      String key;
      Set<String> keys = lruCache.getKeySet();
      Iterator<String> itr = keys.iterator();
      while (itr.hasNext()) {
        key = itr.next();
        Document data = lruCache.get(key);
        // check if email in profile object is same as input userId
        String email = "";
        try {
          email = DOMUtil.value(data, Profile.xpathMap.get("email"));
        } catch (XMLException e) {
          continue;
        }

        // cache hit
        if (StringUtil.equalsIgnoreCase(email, userId)) {
          lruCache.remove(key);
        }
      }
      // Cache miss

    } else {
      lruCache.remove(userId);
    }
    if (logger.isLoggable(Level.FINEST)) {
      logger.exiting(sourceClass, "removeProfileDataFromCache");
    }
  }
Exemple #2
0
 /**
  * Clear the whole cache.
  */
 public synchronized void clear() {
     synchronized(cache){
         for(String key : keys){
             super.remove(key);
             File fileForKey = getFileForKey(key);
             fileForKey.delete();
         }
         keys.clear();
     }        
 }
Exemple #3
0
 /**
  * Removes both: from the memory and from the disk
  */
 public synchronized void remove(String key) {
     synchronized(cache){
         if(DEBUG){
             System.out.println("Disk cache - Removing: "+key);
         }
         super.remove(key);
         File fileForKey = getFileForKey(key);
         fileForKey.delete();
         keys.remove(key);
     }
 }
 /**
  * Remove key-value from cache
  *
  * @param id ItemId the key
  */
 public void remove(ItemId id) {
   if (maxCacheSize < 1) {
     return;
   }
   readAccessCache.remove(id);
 }