common / com.revenuecat.purchases.common.caching / DeviceCache

DeviceCache

class DeviceCache

Constructors

<init>

DeviceCache(preferences: SharedPreferences, apiKey: String, offeringsCachedObject: InMemoryCachedObject<Offerings> = InMemoryCachedObject(), dateProvider: DateProvider = DefaultDateProvider())

Properties

appUserIDCacheKey

val appUserIDCacheKey: String

attributionCacheKey

val attributionCacheKey: String

cachedOfferings

val cachedOfferings: Offerings?

legacyAppUserIDCacheKey

val legacyAppUserIDCacheKey: String

subscriberAttributesCacheKey

val subscriberAttributesCacheKey: String

tokensCacheKey

val tokensCacheKey: String

Functions

addSuccessfullyPostedToken

fun addSuccessfullyPostedToken(token: String): Unit

cacheAppUserID

fun cacheAppUserID(appUserID: String): Unit

cacheAttributionData

fun cacheAttributionData(network: AttributionNetwork, userId: String, cacheValue: String): Unit

cacheOfferings

fun cacheOfferings(offerings: Offerings): Unit

cachePurchaserInfo

fun cachePurchaserInfo(appUserID: String, info: PurchaserInfo): Unit

cleanPreviouslySentTokens

Removes from the database all hashed tokens that are not considered active anymore, i.e. all consumed in-apps or inactive subscriptions hashed tokens that are still in the local cache.

fun cleanPreviouslySentTokens(activeSubsHashedTokens: Set<String>, unconsumedInAppsHashedTokens: Set<String>): Unit

clearCachesForAppUserID

fun clearCachesForAppUserID(appUserID: String): Unit

clearLatestAttributionData

fun clearLatestAttributionData(userId: String): Unit

clearOfferingsCacheTimestamp

fun clearOfferingsCacheTimestamp(): Unit

clearPurchaserInfoCache

fun clearPurchaserInfoCache(appUserID: String): Unit

clearPurchaserInfoCacheTimestamp

fun clearPurchaserInfoCacheTimestamp(appUserID: String): Unit

findKeysThatStartWith

fun findKeysThatStartWith(cacheKey: String): Set<String>

getActivePurchasesNotInCache

Returns a list containing all tokens that are in activeSubsByTheirHashedToken and activeInAppsByTheirHashedToken map that are not present in the device cache. In other words, returns all hashed tokens that are active and have not been posted to our backend yet.

fun getActivePurchasesNotInCache(activeSubsByTheirHashedToken: Map<String, PurchaseWrapper>, activeInAppsByTheirHashedToken: Map<String, PurchaseWrapper>): List<PurchaseWrapper>

getCachedAppUserID

fun getCachedAppUserID(): String?

getCachedAttributionData

fun getCachedAttributionData(network: AttributionNetwork, userId: String): String?

getCachedPurchaserInfo

fun getCachedPurchaserInfo(appUserID: String): PurchaserInfo?

getJSONObjectOrNull

fun getJSONObjectOrNull(key: String): JSONObject?

getLegacyCachedAppUserID

fun getLegacyCachedAppUserID(): String?

getPreviouslySentHashedTokens

fun getPreviouslySentHashedTokens(): Set<String>

getPurchaserInfoCachesLastUpdated

fun getPurchaserInfoCachesLastUpdated(appUserID: String): Date?

isOfferingsCacheStale

fun isOfferingsCacheStale(appInBackground: Boolean): Boolean

isPurchaserInfoCacheStale

fun isPurchaserInfoCacheStale(appUserID: String, appInBackground: Boolean): Boolean

newKey

fun newKey(key: String): String

purchaserInfoCacheKey

fun purchaserInfoCacheKey(appUserID: String): String

purchaserInfoLastUpdatedCacheKey

fun purchaserInfoLastUpdatedCacheKey(appUserID: String): String

putString

fun putString(cacheKey: String, value: String): Unit

remove

fun remove(cacheKey: String): Unit

setOfferingsCacheTimestampToNow

fun setOfferingsCacheTimestampToNow(): Unit

setPurchaserInfoCacheTimestamp

fun setPurchaserInfoCacheTimestamp(appUserID: String, date: Date): Unit

setPurchaserInfoCacheTimestampToNow

fun setPurchaserInfoCacheTimestampToNow(appUserID: String): Unit