Closed sergio-genies closed 2 months ago
Maybe just have PlayerPrefs as an async method
internal void updateUserValues(StatsigUser user, string values)
{
try
{
var stopwatch = new Stopwatch();
stopwatch.Start();
var cacheKey = getUserValueKey(user);
if (cacheKey == currentUserCacheKey)
{
ParseAndSaveInitResponse(values);
}
storeDataPersistently(cacheKey, values);
Debug.Log($"[Statsig] Player Prefs completed in {stopwatch.ElapsedMilliseconds} ms.");
}
catch (Exception e)
{
}
}
internal async Task storeDataPersistently(string cacheKey, string values)
{
await Task.Run(() =>
{
PlayerPrefs.SetString(cacheKey, values);
PlayerPrefs.Save();
});
}
@sergio-genies We just released sdk version 0.8.0 which adds an option (EnableAsyncCacheWrites) to StatsigOptions which will enable the logic you recommended for the fix.
We are currently facing an initialization issue due to the PersistentStore class. We heavily rely on Statsig, which results in a large response. Based on unity documentation, PlayerPrefs.SetString() recommends a value of 2KB or smaller, but Statsig surpasses this limit. Consequently, the updateUserValues method becomes very slow when processing a 90KB JSON file, taking around 3700ms to complete.
On our side, we're doing our due diligence to properly deprecate unused flags. However, the correct usage of PlayerPrefs would limit us to keeping only 10 feature flags, which is not ideal.