Online Maps  v3
OnlineMapsCache Class Reference

Class for caching tiles in memory and the file system. More...

Inheritance diagram for OnlineMapsCache:
IOnlineMapsSavableComponent

Public Types

enum  CacheLocation { CacheLocation.persistentDataPath, CacheLocation.custom }
 Location of the file cache More...
 

Public Member Functions

void ClearAllCaches ()
 Clear all caches. More...
 
OnlineMapsSavableItem[] GetSavableItems ()
 Returns an array of items to save More...
 
void AddItem (string key, byte[] bytes=null)
 Saves data in custom cache by the key. More...
 
void ClearCustomCache ()
 Clear custom cache More...
 
int GetCustomCacheSizeFast ()
 Fast way to get the size of the file cache. More...
 
byte[] GetItem (string key)
 Returns value from custom cache by key. More...
 
void ClearFileCache ()
 Clear file cache. More...
 
StringBuilder GetFileCacheFolder ()
 Gets the file cache folder. More...
 
int GetFileCacheSizeFast ()
 Fast way to get the size of the file cache. More...
 
StringBuilder GetShortTilePath (OnlineMapsTile tile)
 Get the relative path to the tile in the file cache. More...
 
void ClearMemoryCache ()
 Clear memory cache. More...
 

Static Public Member Functions

static void Add (string key, byte[] bytes=null)
 Saves data in custom cache by the key. More...
 
static byte[] Get (string key)
 Returns value from custom cache by key. More...
 

Public Attributes

Action< OnlineMapsTileOnLoadedFromCache
 Event occurs when loading the tile from the file cache or memory cache. More...
 
float customCacheUnloadRate = 0.3f
 Rate of unloaded tiles from the file cache (0-1). More...
 
int maxCustomCacheSize = 100
 The maximum size of the file cache (mb). More...
 
Action< OnlineMapsTileOnLoadedFromFileCache
 Event occurs when loading the tile from the file cache. More...
 
CacheLocation fileCacheLocation = CacheLocation.persistentDataPath
 Location of the file cache. More...
 
string fileCacheCustomPath
 Custom file cache path. More...
 
string fileCacheTilePath = "TileCache/{pid}/{mid}/{lbs}/{lng}/{zoom}/{x}/{y}"
 Template file name in the file cache. More...
 
float fileCacheUnloadRate = 0.3f
 Rate of unloaded tiles from the file cache (0-1). More...
 
int maxFileCacheSize = 100
 The maximum size of the file cache (mb). More...
 
bool useFileCache = true
 Flag indicating that the file cache is used. More...
 
Action< OnlineMapsTileOnLoadedFromMemoryCache
 Event occurs when loading the tile from the memory cache. More...
 
int maxMemoryCacheSize = 10
 The maximum size of the memory cache (mb). More...
 
float memoryCacheUnloadRate = 0.3f
 Rate of unloaded tiles from the memory cache (0-1). More...
 
bool useMemoryCache = true
 Flag indicating that the memory cache is used. More...
 

Properties

static OnlineMapsCache instance [get]
 The reference to an instance of the cache. More...
 
int fileCacheSize [get]
 The current size of the file cache (mb). More...
 
int memoryCacheSize [get]
 The current size of the memory cache (mb). More...
 

Detailed Description

Class for caching tiles in memory and the file system.

Member Enumeration Documentation

◆ CacheLocation

Location of the file cache

Enumerator
persistentDataPath 

Application.persistentDataPath

custom 

Custom

Member Function Documentation

◆ Add()

static void OnlineMapsCache.Add ( string  key,
byte[]  bytes = null 
)
static

Saves data in custom cache by the key.

Parameters
keyThe unique key of the value.
bytesThe value to be stored.

◆ AddItem()

void OnlineMapsCache.AddItem ( string  key,
byte[]  bytes = null 
)

Saves data in custom cache by the key.

Parameters
keyThe unique key of the value.
bytesThe value to be stored.

◆ ClearAllCaches()

void OnlineMapsCache.ClearAllCaches ( )

Clear all caches.

◆ ClearCustomCache()

void OnlineMapsCache.ClearCustomCache ( )

Clear custom cache

◆ ClearFileCache()

void OnlineMapsCache.ClearFileCache ( )

Clear file cache.

◆ ClearMemoryCache()

void OnlineMapsCache.ClearMemoryCache ( )

Clear memory cache.

◆ Get()

static byte [] OnlineMapsCache.Get ( string  key)
static

Returns value from custom cache by key.

Parameters
keyThe unique key of the value.
Returns
Value of null.

◆ GetCustomCacheSizeFast()

int OnlineMapsCache.GetCustomCacheSizeFast ( )

Fast way to get the size of the file cache.

Returns
Size of the file cache (bytes)

◆ GetFileCacheFolder()

StringBuilder OnlineMapsCache.GetFileCacheFolder ( )

Gets the file cache folder.

Returns
File cache folder

◆ GetFileCacheSizeFast()

int OnlineMapsCache.GetFileCacheSizeFast ( )

Fast way to get the size of the file cache.

Returns
Size of the file cache (bytes)

◆ GetItem()

byte [] OnlineMapsCache.GetItem ( string  key)

Returns value from custom cache by key.

Parameters
keyThe unique key of the value.
Returns
Value of null.

◆ GetSavableItems()

OnlineMapsSavableItem [] OnlineMapsCache.GetSavableItems ( )

Returns an array of items to save

Returns
Array of items to save

Implements IOnlineMapsSavableComponent.

◆ GetShortTilePath()

StringBuilder OnlineMapsCache.GetShortTilePath ( OnlineMapsTile  tile)

Get the relative path to the tile in the file cache.

Parameters
tileTile
Returns
Relative path to the tile in the file cache

Member Data Documentation

◆ customCacheUnloadRate

float OnlineMapsCache.customCacheUnloadRate = 0.3f

Rate of unloaded tiles from the file cache (0-1).

◆ fileCacheCustomPath

string OnlineMapsCache.fileCacheCustomPath

Custom file cache path.

◆ fileCacheLocation

CacheLocation OnlineMapsCache.fileCacheLocation = CacheLocation.persistentDataPath

Location of the file cache.

◆ fileCacheTilePath

string OnlineMapsCache.fileCacheTilePath = "TileCache/{pid}/{mid}/{lbs}/{lng}/{zoom}/{x}/{y}"

Template file name in the file cache.

◆ fileCacheUnloadRate

float OnlineMapsCache.fileCacheUnloadRate = 0.3f

Rate of unloaded tiles from the file cache (0-1).

◆ maxCustomCacheSize

int OnlineMapsCache.maxCustomCacheSize = 100

The maximum size of the file cache (mb).

◆ maxFileCacheSize

int OnlineMapsCache.maxFileCacheSize = 100

The maximum size of the file cache (mb).

◆ maxMemoryCacheSize

int OnlineMapsCache.maxMemoryCacheSize = 10

The maximum size of the memory cache (mb).

◆ memoryCacheUnloadRate

float OnlineMapsCache.memoryCacheUnloadRate = 0.3f

Rate of unloaded tiles from the memory cache (0-1).

◆ OnLoadedFromCache

Action<OnlineMapsTile> OnlineMapsCache.OnLoadedFromCache

Event occurs when loading the tile from the file cache or memory cache.

◆ OnLoadedFromFileCache

Action<OnlineMapsTile> OnlineMapsCache.OnLoadedFromFileCache

Event occurs when loading the tile from the file cache.

◆ OnLoadedFromMemoryCache

Action<OnlineMapsTile> OnlineMapsCache.OnLoadedFromMemoryCache

Event occurs when loading the tile from the memory cache.

◆ useFileCache

bool OnlineMapsCache.useFileCache = true

Flag indicating that the file cache is used.

◆ useMemoryCache

bool OnlineMapsCache.useMemoryCache = true

Flag indicating that the memory cache is used.

Property Documentation

◆ fileCacheSize

int OnlineMapsCache.fileCacheSize
get

The current size of the file cache (mb).

◆ instance

OnlineMapsCache OnlineMapsCache.instance
staticget

The reference to an instance of the cache.

◆ memoryCacheSize

int OnlineMapsCache.memoryCacheSize
get

The current size of the memory cache (mb).