Instance cache
Inspect and replace cached instance wrappers, clone references and compare objects.
The cache maps native Instance addresses to their current Luau wrappers. Removing an entry does not destroy the Instance or invalidate every existing Lua reference. These helpers still use the Instance bridge, rather than accepting arbitrary Object userdata.
cache.invalidate
cache.invalidate(instance: Instance): ()Removes the wrapper-cache entry for an Instance. A later native push can create another wrapper for the same native object. If the native cache table is unavailable, the function returns without changes.
Parameters
instanceInstance- Instance whose cache mapping is removed.
Returns
()No values.
Example
cache.replace
cache.replace(instance: Instance, replacement: userdata): ()Sets the cache entry keyed by instance to replacement. The first argument must resolve through the Instance bridge; the second currently receives only a userdata type check.
Parameters
instanceInstance- Native object whose wrapper mapping changes.
replacementuserdata- Replacement wrapper; use an Instance wrapper for normal cache use.
Returns
()No values; no change when the cache table is unavailable.
Example
cache.iscached
cache.iscached(instance: Instance): boolean?Checks whether the native wrapper cache contains a non-nil entry for this Instance address. If the cache table itself is unavailable, the implementation returns no values.
Also available as iscached.
Parameters
instanceInstance- Instance whose address is looked up.
Returns
boolean?Entry presence, or nil when the cache table is missing.
Example
Written for Lynx 0.0.0
Something unclear? Tell us on Discord