コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
  /** 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();
    }
  }
コード例 #3
0
 /**
  * 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();
   }
 }
コード例 #4
0
 /**
  * Private parameterized constructor.
  *
  * @param account User account.
  * @param communityId Community ID.
  */
 private CacheManager(UserAccount account, String communityId) {
   smartStore = SmartSyncSDKManager.getInstance().getSmartStore(account, communityId);
   resetInMemoryCache();
 }