API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classAssetCache
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.
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.
new(options: AssetCacheOptionsConstruction options for an AssetCache.): AssetCacheclear(namespace?: string): Promise<void>destroy(): void