Cache
SDK uses 2 types of cache - temporal, that dies with app session (memcache) and persistent (lru cache and shared preferences). When user session reopens or app closes - all memcache data clears but persistent data remains.
Stories
Stories list
Stories list caches its models in memcache by set of parameters as a key: tags, cacheId, feed. It
also has 2 methods for load data - loadStories and refresh.
In case of loadStories is called - stories list tries to get cached models and if it fails - tries
to load data from backend (overrides or stores data in cache by key in success case). It also gets
favorite
ids from backend. Otherwise - list uses local data and loads only covers if needed (or uses it from
persistent file cache).
In case of refresh is called - stories list ignores cached models and tries to load data from
backend
(overrides or stores data in cache by key in success case).
Covers (images/videos) of stories list items are saved in persistent cache.
Stories reader
Stories reader uses its own models, that store in memcache and renew in 2 cases: reopening
session or if showStory method is called. In another cases reader firstly tries to get data from
cache. It also loads all content (images / videos) for slides in lru cache. Also, started from
version 1.25.1 reader stores layout to persistent cache.
In-app messages
In-app messages has two methods to load models - "by id" and "by event". "By event" SDK always gets all available messages for current set of tags, saves these models by its ids and also saves current tags as a "check key". If cache already has current "check key" - SDK uses local models (or throws an error if not possible) instead of requesting from the backend. "By id" SDK tries to get local model by id and if fails - gets concrete model for message from backend and stores it with id as a key. All content (images / videos) for slides is stored in lru cache. Also, started from version 1.25.1 reader stores layout to persistent cache.
Banners
Banners has 3 methods to load data - loadBanners(), reloadBanners()
and loadBanners(skipCache: Boolean).
Method loadBanners() equals loadBanners(false) and reloadBanners() equals loadBanners(true).
You also can load data with InAppStoryManager.loadBannerPlace that skips cache. Also in this case
it syncs data for all banner widgets with same bannerPlace.
All content (images / videos) for slides is stored in lru cache. Also, started from version 1.25.1
reader stores layout to persistent cache.
Games
Each time a user calls openGame or game opens from another content - new model is retrieved from
backend. All files (archive, resources) are stored in persistent cache.
Every time you open a game if it has a loading screen (image or lottie animation), SDK tries to find
cached instance. If it fails - it loads from backend. So if the game instance's loading screen was changed
between launch sessions - game will be opened with old version of loading screen if it was cached
but new version will be saved and used in next launch.
Files
All files for slides are stored in lru cache.
There are 5 types of LruCache storages for different files:
fastCache - uses for story covers
commonCache - uses for slides content (images / common videos)
infiniteCache - uses for game files and layout file (from 1.25.1)
vodCache - uses for vod videos
bundleCache - uses for assets
Fast, common and vod caches have limited size, bundle and infinite caches are limited only by the device's free storage size.
SDK has InAppStoryManager.clearCache method. It cleans all lru caches but bundleCache. Assets
are stored forever, but can be renewed in case of different sha1.
Others
In 1.25.1 shared layout for all type of contents was released. Each time SDK opens session - it checks if layout was updated or not. If it was - SDK gets new version of layout from backend.