Class: Cache

PIXI.Cache

A single Cache for all assets.

When assets are added to the cache via set they normally are added to the cache as key-value pairs.

With this cache, you can add parsers that will take the object and convert it to a list of assets that can be cached. for example a cacheSprite Sheet parser will add all of the textures found within its sprite sheet directly to the cache.

This gives devs the flexibility to cache any type of object however we want.

It is not intended that this class is created by developers - it is part of the Asset package. This is the first major system of PixiJS' main Assets class.

new PIXI.Cache

A single Cache for all assets.

Members

parsers CacheParser[]

All loader parsers registered

Methods

get (key) T

Fetch entry by key

Name Type Description
key string

The key of the entry to get

Returns:
Type Description
T

has (key) boolean

Check if the key exists

Name Type Description
key string

The key to check

Returns:
Type Description
boolean

remove (key) void

Remove entry by key

This function will also remove any associated alias from the cache also.

Name Type Description
key string

The key of the entry to remove

reset () void

Clear all entries.

set (key, value) void

Set a value by key or keys name

Name Type Description
key string | string[]

The key or keys to set

value unknown

The value to store in the cache or from which cacheable assets will be derived.