SleepCacheConfiguration

data class SleepCacheConfiguration(val enabled: Boolean = false, val lastCachedDaysBack: Int = 0, val cachedDaysCount: Int = 7, val sleepGap: Long = Sleep.SLEEP_GAP, val cacheClearingDelay: Long = 2)

Settings for sleep cache.

Sleep data could fall into several days and to avoid parsing some days several times cache may be used. Data cached only when there are subscriptions to observe* methods and cache is cleared when all subscriptions disposed. So enabling of cache doesn't affect memory usage when sleep data is not used.

cacheClearingDelay is used to delay cache clearing on dispose of all subscription. So it is safe to go from one activity to another. SleepData.clearCache could be used to clear cache manually and the method has parameter to clear cache immediately.

Episodes of sleep are used for almost every type of sleep data. But anxiety in sleep are cached only when there are subscription to SleepData.observeAnxietyData.

Constructors

Link copied to clipboard
fun SleepCacheConfiguration(enabled: Boolean = false, lastCachedDaysBack: Int = 0, cachedDaysCount: Int = 7, sleepGap: Long = Sleep.SLEEP_GAP, cacheClearingDelay: Long = 2)

Properties

Link copied to clipboard

Amount of seconds to delay clearing of cache. Default: 2 seconds.

Link copied to clipboard

Count of cached days. Default: 7.

Link copied to clipboard
val enabled: Boolean = false

true if caching is enable, and false if it is disable. Default: false.

Link copied to clipboard

Last of cached days in terms of days ago from today. Default: 0 (cache cachedDaysCount days from today including today).

Link copied to clipboard

Amount of seconds to break episodes of sleep in two different Sleep. Default: Sleep.SLEEP_GAP.