LayoutCache
import { LayoutCache } from 'pixi-silk/i18n';
A least-recently-used cache of laid out messages with a memory budget (brief sec. 8). Messages that show the same variant, values, size and width share one layout. Entries are immutable: a message that updates a slot in place clones its layout first (cloneLayout).
Constructors#
Constructor#
new LayoutCache(budget?: number): LayoutCache;
Parameters#
| Parameter | Type |
|---|---|
budget | number |
Returns#
LayoutCache
Properties#
Accessors#
bytes#
Get Signature#
get bytes(): number;
Estimated bytes in use.
Returns
number
size#
Get Signature#
get size(): number;
Entries in the cache.
Returns
number
Methods#
clear()#
clear(): void;
Empties the cache.
Returns#
void
get()#
get(key: string): MessageLayout | undefined;
The layout for a key, marked as recently used, or undefined.
Parameters#
| Parameter | Type |
|---|---|
key | string |
Returns#
MessageLayout | undefined
set()#
set(key: string, layout: MessageLayout): void;
Stores a layout and evicts the least recently used ones past the budget.
Parameters#
| Parameter | Type |
|---|---|
key | string |
layout | MessageLayout |
Returns#
void