/**
  * Returns the instance of this class associated with this user and community.
  *
  * @param account User account.
  * @param communityId Community ID.
  * @return Instance of this class.
  */
 public static synchronized CacheManager getInstance(UserAccount account, String communityId) {
   if (account == null) {
     account = SmartStoreSDKManager.getInstance().getUserAccountManager().getCurrentUser();
   }
   if (account == null) {
     return null;
   }
   String uniqueId = account.getUserId();
   if (UserAccount.INTERNAL_COMMUNITY_ID.equals(communityId)) {
     communityId = null;
   }
   if (!TextUtils.isEmpty(communityId)) {
     uniqueId = uniqueId + communityId;
   }
   CacheManager instance = null;
   if (INSTANCES == null) {
     INSTANCES = new HashMap<String, CacheManager>();
     instance = new CacheManager(account, communityId);
     INSTANCES.put(uniqueId, instance);
   } else {
     instance = INSTANCES.get(uniqueId);
   }
   if (instance == null) {
     instance = new CacheManager(account, communityId);
     INSTANCES.put(uniqueId, instance);
   }
   instance.resetInMemoryCache();
   return instance;
 }
  /** Clears the cache and creates a new clean cache. */
  private void cleanCache() {
    resetInMemoryCache();

    // Checks to make sure SmartStore hasn't already been cleaned up.
    if (SmartSyncSDKManager.getInstance().hasSmartStore()) {
      clearAllSoups();
    }
  }
 /**
  * Removes existing data from the specified cache.
  *
  * @param cacheType Cache type.
  * @param cacheKey Cache key.
  */
 public void removeCache(String cacheType, String cacheKey) {
   if (cacheType == null
       || cacheKey == null
       || Constants.EMPTY_STRING.equals(cacheType)
       || Constants.EMPTY_STRING.equals(cacheKey)) {
     return;
   }
   if (doesCacheExist(cacheType)) {
     smartStore.dropSoup(cacheType);
     removeSoupNameFromMasterSoup(cacheType);
     resetInMemoryCache();
   }
 }
 /**
  * Private parameterized constructor.
  *
  * @param account User account.
  * @param communityId Community ID.
  */
 private CacheManager(UserAccount account, String communityId) {
   smartStore = SmartSyncSDKManager.getInstance().getSmartStore(account, communityId);
   resetInMemoryCache();
 }