Interface InfiniteCacheInterface

The InfiniteCacheInterface is based on IndexedDB to limit the bandwidth usage, and speed up the loading and displaying of data when using a DataSessionInterface.

The initialization sizes of the cache are stored in the LocalStorage of the browser. The former values that were set will be used when creating a new cache / reloading the page.

The InfiniteCacheInterface handles two types of data :

  • build data : i.e. initialization data, if such data is cached, the DMU loading will be a lot faster
  • HD geometric data : upon navigation, the 3djuump Infinite resource loader of the InfiniteEngineInterface loads high definition geometric data to display the most accurate version of the DMU given the budget allocated to the display of resources. Such HD data is cached in the InfiniteCacheInterface.

The two types of data are handled separately in the InfiniteCacheInterface.

The connection procedure to IndexedDB is started when the InfiniteCacheInterface is created. The isConnected will return true shortly after creation if IndexedDB is available.

/** 
* Sample to illustrate the use of a cache (InfiniteCacheInterface) in a DataSessionInterface.
*/
import {
InfiniteCacheInterface, InfiniteCacheFactory, DirectorySessionInterface, DataSessionInterfaceSignal, tListenerCallback,
DataSessionInterface,
} from 'generated_files/documentation/appinfiniteapi';

// created previously
let lDirectorySession : DirectorySessionInterface;
// callback called when the DMU is loaded
let onDMULoaded : tListenerCallback;
// the build id to connect to
let lBuildId : string;

// Infinite cache creation
const lCache : InfiniteCacheInterface = InfiniteCacheFactory.CreateInfiniteCache();

// create a data session with a cache
const lDataSession : DataSessionInterface | undefined = lDirectorySession.createDataSession(lBuildId, lCache);
if (lDataSession)
{
// be ready to do something when build is ready (i.e. all init data has been parsed and server is ready)
lDataSession.addEventListener(DataSessionInterfaceSignal.DMULoadingSuccess, onDMULoaded);
// and go !!! => open the data session
lDataSession.openDataSession();
}

The InfiniteCacheInterface only exposes getters, the cache manipulation is available through the InfiniteCachePerformanceInterface, the InfiniteCachePerformanceInterface also lists absolute minimum and default values (InfiniteCachePerformanceInterface.GetMaxBuildCacheSizeMin, InfiniteCachePerformanceInterface.GetMaxBuildCacheSizeDefault, ...). The InfiniteCachePerformanceInterface is accessible through the getPerformance function.
/** 
* Sample to illustrate the use of modifying the cache (InfiniteCacheInterface, PerformanceInterface) settings.
*/
import { InfiniteCacheInterface, InfiniteCachePerformanceInterface } from 'generated_files/documentation/appinfiniteapi';

// created previously
let lCache : InfiniteCacheInterface;
// get the performance interface
const lPerformanceInfos : InfiniteCachePerformanceInterface = lCache.getPerformance();
// the cache sizes to modify
// 1GB for build data
const lMaxBuildCacheSize : number = 1 * 1024 * 1024 * 1024;
// 1GB for HD geometry data
const lMaxGeometryCacheSize : number = 1 * 1024 * 1024;

console.assert(lPerformanceInfos.getMaxBuildCacheSize() === lCache.getMaxBuildSize());
console.assert(lPerformanceInfos.getMaxGeometryCacheSize() === lCache.getMaxHDSize());

console.assert(lPerformanceInfos.getCurrentBuildCacheSize() === lCache.getCurrentBuildSize());
console.assert(lPerformanceInfos.getCurrentGeometryCacheSize() === lCache.getCurrentHDSize());

lPerformanceInfos.setMaxBuildCacheSize(lMaxBuildCacheSize);
lPerformanceInfos.setMaxGeometryCacheSize(lMaxGeometryCacheSize);

Please refer to DataSessionInterface for more information.
Sessions

interface InfiniteCacheInterface {
    clearCache(): boolean;
    getCurrentBuildSize(): number;
    getCurrentHDSize(): number;
    getMaxBuildSize(): number;
    getMaxHDSize(): number;
    getPerformance(): InfiniteCachePerformanceInterface;
    isConnected(): boolean;
}

Methods

  • Clears the cache, i.e. removes all data (build data and HD data).

    This procedure may take some time.

    Returns boolean

    false if cache is not connected.

  • Gets the current number of bytes used to store build data (in bytes) in the cache.

    Returns number

    The current number of bytes used to store build data (in bytes) in the cache.

  • Gets the current number of bytes used to store HD geometries (in bytes) in the cache.

    Returns number

    The current number of bytes used to store HD geometries (in bytes) in the cache.

  • Indicates if the cache is connected (indexedDb is available and cache has been connected).

    Returns boolean

    true if the cache is connected.