Skip to content

Local Cache

Overview

When you project cannot reach the Internet, data is written to a local file. When a session is run and internet is available, the contents of this file will automatically upload in the background. This works between sessions, so you can freely start more sessions even when offline.

Cache Size

Click cognitive3D->Advanced Options to change the Upload Local Cache Rate and the Cache Size. If more session data is recorded and the cache doesn't have enough space allocated, the most recent session data may be lost.

Where are the cache located?

The local data cache is in the c3dlocal folder in Application.PersistentDataPath. This is different for each platform. This has been tested on Windows 10 and Android.

A benefit from saving the session data to the PersistentDataPath is that this saved data will persist to newer versions of your app (or even if you uninstall your app).

When is data read from the cache?

The data from the cache is read and removed when you have an internet connection and while running the application. A cvr-request-time response header is checked to determine if the device is connected to the internet and not blocked by a capture portal (for example, a login page on hotel wifi).

Manually sending data from Local Data Cache

You can manually send data from the cache using the following code:

CognitiveVR.NetworkManager.UploadAllLocalData(
    () => Debug.Log("complete"),
    () => Debug.Log("failed"));

This will quickly try to upload all outstanding requests and invoke the callbacks when it is completed. This will fail if the device is offline or if Local Storage is disabled. You do not need to start a Session to call this function.

Use the following code to get 0.0-1.0 for the percent the local cache is full. This will also write to the console by default.

float fullPercent = CognitiveVR.LocalCache.GetLocalStorage(mute:false);