Solved

SDK Cache

  • 17 November 2021
  • 3 replies
  • 501 views

Badge +5

In the SDK docs it is mentioned that the SDK caches user information. What is the TTL on the cache information? How stale can the information get? If a user leaves the app in the background for a few days does the SDK refetch information when the app is opened back up?

 

https://docs.revenuecat.com/docs/purchaserinfo#get-user-information

 

 

icon

Best answer by ryan 18 November 2021, 03:24

View original

3 replies

Userlevel 5
Badge +9

Hey @Omer Winrauke!

The cache is 5mins, so when the app fires up or getPurchaserInfo is called a network request is made if the cache is >5mins stale.

However, it’s worth noting that the PurchaserInfo in the cache is always returned first. If a network request needs to be made this is done in the background. The reason for this is so you can check the purchaserInfo as often as you need and it will always return fast, creating a synchronous experience for your customers. 

Badge +1

Hi, is it possible to get `CustomerInfo` from the cache without a network call?

Eg on app launch, it would be great to have immediate access to the most recent `CustomerInfo` object.

Currently I am calling `Purchases.shared.getCustomerInfo` on app launch but it returns async after a network call.

It looks like `Purchases.shared.customerInfoManager.lastSentCustomerInfo` might be the place but it is private.

https://docs.revenuecat.com/docs/purchaserinfo

Userlevel 1
Badge +6

Does this cach persistis after the app is closed and reopened again without internet connection?

Like, suppose the app is launched with an active internet connection, in which case RevenueCat’s SDK will fetch CustomerInfo and then cache it. Then suppose the app is closed and reopened some time later, now without an active internet connection. Will the cached data be available in this scenario?

Reply