API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classAssetCache

@codexo/exojs / assets / stable

The application's caching configuration: which stores exist, which asset types use which of them, and in what order the cache and the network are consulted. The common case needs none of this vocabulary - passing a store straight to the loader configures one cache-first route over it: ```ts new Application({ loader: { cache: new IndexedDbStore('my-game') } }); ``` The full form exists for applications that need more than one tier or more than one policy: ```ts new Application({ loader: { cache: new AssetCache({ read: [memory, persistent], write: [persistent], promote: true, routes: [new CacheRoute({ types: ['config'], policy: new NetworkFirstPolicy(), stores: persistent })], }), }, }); ``` ## What it does not do An `AssetCache` never builds a resource, never reads a `Response` and never decides how a representation is serialized. It selects a route, hands the route's policy a CacheContext, and turns that context's record reads and writes into store calls. Representation is the asset type's; construction is the factory's. It also holds no connectivity and knows no application. Whether an acquisition may reach the network arrives WITH the acquisition, so one cache can serve two applications that disagree about it.

0
props
3
methods
0
events
Import
import { AssetCache } from '@codexo/exojs'

The application's caching configuration: which stores exist, which asset types use which of them, and in what order the cache and the network are consulted.

The common case needs none of this vocabulary - passing a store straight to the loader configures one cache-first route over it:

```ts new Application({ loader: { cache: new IndexedDbStore('my-game') } }); ```

The full form exists for applications that need more than one tier or more than one policy:

```ts new Application({ loader: { cache: new AssetCache({ read: [memory, persistent], write: [persistent], promote: true, routes: [new CacheRoute({ types: ['config'], policy: new NetworkFirstPolicy(), stores: persistent })], }), }, }); ```

## What it does not do

An `AssetCache` never builds a resource, never reads a `Response` and never decides how a representation is serialized. It selects a route, hands the route's policy a CacheContext, and turns that context's record reads and writes into store calls. Representation is the asset type's; construction is the factory's.

It also holds no connectivity and knows no application. Whether an acquisition may reach the network arrives WITH the acquisition, so one cache can serve two applications that disagree about it.

Constructors1
Methods3
clear(namespace?: string): Promise<void>
Drop cached records: those of one asset type, or every record in every store this cache knows. Rejects with the first failure a store reported, after attempting all of them. Assets are re-fetchable, so a partial clear is not a state that needs unwinding.
destroy(): void
Destroys every store this cache holds, each exactly once.
Source