Class: CacheManager

Phaser.Cache. CacheManager

The Cache Manager is the global cache owned and maintained by the Game instance.

Various systems, such as the file Loader, rely on this cache in order to store the files it has loaded. The manager itself doesn't store any files, but instead owns multiple BaseCache instances, one per type of file. You can also add your own custom caches.


new CacheManager(game)

Parameters:
Name Type Description
game Phaser.Game

A reference to the Phaser.Game instance that owns this CacheManager.

Since: 3.0.0
Source: src/cache/CacheManager.js (Line 11)

Members


audio :Phaser.Cache.BaseCache

A Cache storing all non-streaming audio files, typically added via the Loader.

Type:
Since: 3.0.0
Source: src/cache/CacheManager.js (Line 88)

binary :Phaser.Cache.BaseCache

A Cache storing all binary files, typically added via the Loader.

Type:
Since: 3.0.0
Source: src/cache/CacheManager.js (Line 42)

bitmapFont :Phaser.Cache.BaseCache

A Cache storing all bitmap font data files, typically added via the Loader. Only the font data is stored in this cache, the textures are part of the Texture Manager.

Type:
Since: 3.0.0
Source: src/cache/CacheManager.js (Line 51)

custom :Object.<Phaser.Cache.BaseCache>

An object that contains your own custom BaseCache entries. Add to this via the addCustom method.

Type:
Since: 3.0.0
Source: src/cache/CacheManager.js (Line 152)

<protected> game :Phaser.Game

A reference to the Phaser.Game instance that owns this CacheManager.

Type:
Since: 3.0.0
Source: src/cache/CacheManager.js (Line 32)

html :Phaser.Cache.BaseCache

A Cache storing all html files, typically added via the Loader.

Type:
Since: 3.12.0
Source: src/cache/CacheManager.js (Line 115)

json :Phaser.Cache.BaseCache

A Cache storing all JSON data files, typically added via the Loader.

Type:
Since: 3.0.0
Source: src/cache/CacheManager.js (Line 61)

obj :Phaser.Cache.BaseCache

A Cache storing all WaveFront OBJ files, typically added via the Loader.

Type:
Since: 3.0.0
Source: src/cache/CacheManager.js (Line 124)

physics :Phaser.Cache.BaseCache

A Cache storing all physics data files, typically added via the Loader.

Type:
Since: 3.0.0
Source: src/cache/CacheManager.js (Line 70)

shader :Phaser.Cache.BaseCache

A Cache storing all shader source files, typically added via the Loader.

Type:
Since: 3.0.0
Source: src/cache/CacheManager.js (Line 79)

text :Phaser.Cache.BaseCache

A Cache storing all text files, typically added via the Loader.

Type:
Since: 3.0.0
Source: src/cache/CacheManager.js (Line 106)

tilemap :Phaser.Cache.BaseCache

A Cache storing all tilemap data files, typically added via the Loader. Only the data is stored in this cache, the textures are part of the Texture Manager.

Type:
Since: 3.0.0
Source: src/cache/CacheManager.js (Line 133)

video :Phaser.Cache.BaseCache

A Cache storing all non-streaming video files, typically added via the Loader.

Type:
Since: 3.20.0
Source: src/cache/CacheManager.js (Line 97)

xml :Phaser.Cache.BaseCache

A Cache storing all xml data files, typically added via the Loader.

Type:
Since: 3.0.0
Source: src/cache/CacheManager.js (Line 143)

Methods


addCustom(key)

Add your own custom Cache for storing your own files. The cache will be available under Cache.custom.key. The cache will only be created if the key is not already in use.

Parameters:
Name Type Description
key string

The unique key of your custom cache.

Since: 3.0.0
Source: src/cache/CacheManager.js (Line 165)
Returns:

A reference to the BaseCache that was created. If the key was already in use, a reference to the existing cache is returned instead.

Type
Phaser.Cache.BaseCache

destroy()

Removes all entries from all BaseCaches and destroys all custom caches.

Since: 3.0.0
Source: src/cache/CacheManager.js (Line 187)