Skip to main content
The StatsigEvaluationsDataAdapter is the default EvaluationsDataAdapter used by a StatsigClient instance. It handles fetching and caching values from Statsig’s servers. If required, you can create your own custom EvaluationsDataAdapter and provide it to the Statsig client via StatsigOptions.dataAdapter.

Overview

Synchronous Behavior (Cache)

When calling StatsigClient.initializeSync, the StatsigEvaluationsDataAdapter will load values from Cache and provide them to the client. The client will also call refresh in the background via StatsigEvaluationsDataAdapter.getDataAsync, leading to values lagging until the next time initializeSync or updateUserSync is called. If you do not want this background refresh to happen, you can pass in disableBackgroundCacheRefresh in the options when calling initializeSync. In practice (Unless an additional update call is made), this means that for the very first session of a given user, there will be no values, and not until the next session will the cache have values.

Asynchronous Behavior (Network)

When calling StatsigClient.initializeAsync, the StatsigEvaluationsDataAdapter will load values from Cache and provide them to the client. The client will then block on a call to StatsigEvaluationsDataAdapter.getDataAsync, allowing the ability to await the latest values from Statsig. If you want the latest values, but do not want to await the asynchronous call, you may call initializeAsync and simply .catch the promise. Note that this could lead to values changing mid-session as newer values arrive from the network.

Advanced Usage

Getting the Data Adapter

You can access the data adapter from your Statsig client instance: