Header menu logo Mibo

IAssetCache Type

Backend-neutral generic asset cache: stores arbitrary user-created assets by string key, with create-or-get semantics.

This is the shareable subset of asset caching. Backend-specific asset services (e.g. raylib's IAssets) extend this interface to add typed loaders that return native GPU/resource handles (Texture2D, Font, Sound, etc.), which are inherently backend-specific.

Example

 /// Each backend registers its own IAssets (which inherits IAssetCache)
 /// under the IAssets key, so resolve via the backend's IAssets type:
 let cache = GameContext.getService<IAssets> ctx
 let config = cache.GetOrCreate("gameConfig", fun () -> loadConfig())
val cache: obj
 Each backend registers its own IAssets (which inherits IAssetCache)
 under the IAssets key, so resolve via the backend's IAssets type:
val config: obj

Instance members

Instance member Description

this.Clear

Full Usage: this.Clear

Modifiers: abstract

Clears all caches (does not dispose GPU resources).

this.Create

Full Usage: this.Create

Parameters:
    key : string
    factory : unit -> 'T

Returns: 'T
Modifiers: abstract
Type parameters: 'T

Creates and caches a custom asset using the provided factory.

key : string
factory : unit -> 'T
Returns: 'T

this.Dispose

Full Usage: this.Dispose

Modifiers: abstract

Disposes all cached assets and clears caches.

this.Get

Full Usage: this.Get

Parameters:
    key : string

Returns: 'T voption
Modifiers: abstract
Type parameters: 'T

Gets a previously created custom asset by key.

key : string
Returns: 'T voption

this.GetOrCreate

Full Usage: this.GetOrCreate

Parameters:
    key : string
    factory : unit -> 'T

Returns: 'T
Modifiers: abstract
Type parameters: 'T

Gets a cached asset or creates it if not present.

This is the preferred method for custom assets - idempotent, ensures assets are created only once.

key : string
factory : unit -> 'T
Returns: 'T

Type something to start searching.