import { Cache } from "../../core/cache/Cache.js";
import { invokeObjectEquals } from "../../core/model/object/invokeObjectEquals.js";
import { invokeObjectHash } from "../../core/model/object/invokeObjectHash.js";

/**
 * Asset instance objects for read-only usage, so we can just keep 1 copy instead of calling {@link Asset#create} every time
 * @type {Cache<Asset, any>}
 */
export const STATIC_ASSET_CACHE = new Cache({
    maxWeight: 128 * 1024 * 1024, //128 Mb,
    keyEqualityFunction: invokeObjectEquals,
    keyHashFunction: invokeObjectHash,
    keyWeigher(asset) {
        return asset.byteSize + 64;
    },
    valueWeigher(v) {
        return 1;
    }
});