pixi.js
    Preparing search index...

    Class CacheAdvanced

    A global cache for all assets in your PixiJS application. The cache system provides fast access to loaded assets and prevents duplicate loading.

    Key Features:

    • Automatic caching of loaded assets
    • Support for custom cache parsers
    • Automatic parsing of complex assets (e.g., spritesheets)
    • Memory management utilities
    Important

    You typically do not need to use this class directly. Use the main Assets class for high-level asset management. Assets.get(key) will automatically use the cache.

    import { Cache } from 'pixi.js';

    // Store an asset in the cache
    Cache.set('myTexture', texture);

    // Retrieve an asset
    const texture = Cache.get('myTexture');

    // Check if an asset exists
    if (Cache.has('myTexture')) {
    // Use the cached asset
    const sprite = new Sprite(Cache.get('myTexture'));
    }

    // Remove an asset from cache
    Cache.remove('myTexture');

    // Clear all cached assets
    Cache.reset();

    The Cache is a core component of PixiJS' asset management system:

    • Used internally by the Assets class
    • Supports automatic parsing via CacheParser
    • Handles complex asset types like spritesheets
    • Manages memory through asset removal
    Important

    This is a singleton class and should not be instantiated directly. Use the exported Cache instance instead.

    Index

    Accessors

    Methods

    Accessors

    Methods

    • Fetch entry by key

      Type Parameters

      • T = any

      Parameters

      • key: any

        The key of the entry to get

      Returns T

    • Check if the key exists

      Parameters

      • key: any

        The key to check

      Returns boolean

    • Remove entry by key

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

      Parameters

      • key: any

        The key of the entry to remove

      Returns void

    • Clear all entries.

      Returns void

    • Set a value by key or keys name

      Parameters

      • key: any

        The key or keys to set

      • value: unknown

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

      Returns void