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 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/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](InfiniteCacheInterface.html) only exposes getters, the cache manipulation is available through the [PerformanceInterface](PerformanceInterface.html), the [PerformanceInterface](PerformanceInterface.html) also lists absolute minimum and default values ([GetMaxBuildCacheSizeMin](PerformanceInterface.html#GetMaxBuildCacheSizeMin), [GetMaxBuildCacheSizeDefault](PerformanceInterface.html#GetMaxBuildCacheSizeDefault), ...).
/** 
* Sample to illustrate the use of modifying the cache (InfiniteCacheInterface, PerformanceInterface) settings.
*/
import { InfiniteCacheInterface, MetadataManagerInterface, PerformanceInterface } from 'generated/documentation/appinfiniteapi';

// created previously
let lCache : InfiniteCacheInterface;
// created previously
let lMetadataManager : MetadataManagerInterface;
// get the performance interface
const lPerformanceInfos : PerformanceInterface = lMetadataManager.getPerformanceInfos();
// 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](DataSessionInterface.html) for more information.
Sessions

See

DataSessionInterface

Hierarchy

  • InfiniteCacheInterface

Methods

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

    This procedure may take some time.

    Returns

    false if cache is not connected.

    Returns boolean

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

    Returns

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

    Returns number

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

    Returns

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

    Returns number

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

    This is the same value that was set by setMaxBuildCacheSize.

    Returns

    The maximum number of bytes used to store build data (in bytes).

    Returns number

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

    This is the same value that was set by setMaxGeometryCacheSize.

    Returns

    The maximum number of bytes used to store HD geometries (in bytes).

    Returns number

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

    Returns

    true if the cache is connected.

    Returns boolean