Cache data
Mobile SDK optimizes the user experience by caching the getCountries
, getCurrencies
, and getMerchantPriceDetails
calls.
You can configure the cache time for each method.
iOS
The cache() method is integrated into Global-E SDK and used to save cache data to the above methods.
You can use the clearCache() method to clear the cache for all requests.
func clearAllCachedResponses() { let urlCache = URLCache.shared urlCache.removeAllCachedResponses() }
Android
GET_MERCHANT_PRICE_DETAILS -> { maxAge = 15 } } val request = chain.request() if (chain.request().url().pathSegments().last() == GET_CART_TOKEN) { return chain.proceed(chain.request()) } return if (cacheManager.canGetFromCache(request)) { cacheManager.getCachedResponse(request) } else { chain.proceed(chain.request()).also { cacheManager.cacheResponse(it, maxAge, TimeUnit.MINUTES) } } } }
fun clearCache(): Boolean { return File("${context.cacheDir}${File.separator}$CACHE_GLOBAL_E").deleteRecursively() }