Cache
The Cache library provides methods for modifying the internal instance cache.
cache.invalidate
Deletesobject
from the Instance cache. Effectively invalidates object
as a reference to the underlying instance.
Parameters
object
- The object to invalidate.
Example
local Lighting = game:GetService("Lighting")
cache.invalidate(game:GetService("Lighting"))
print(Lighting, Lighting == game:GetService("Lighting")) --> Lighting, false
cache.iscached
Checks whetherobject
exists in the Instance cache.
Parameters
object
- The object to find.
Example
local Lighting = game:GetService("Lighting")
cache.invalidate(Lighting)
print(cache.iscached(Lighting)) --> false
cache.replace
Replacesobject
in the Instance cache with newObject
.
Parameters
object
- The object to replace.newObject
- The new object to replaceobject
with.
Example
local Lighting = game:GetService("Lighting")
local Players = game:GetService("Players")
cache.replace(Lighting, Players)
print(Lighting) --> Players
cloneref
Returns a copy of the Instance reference toobject
. This is useful for managing an Instance without directly referencing it.
Parameters
object
- The Instance to clone.
Example
local Lighting = game:GetService("Lighting")
local LightingClone = cloneref(Lighting)
print(Lighting == LightingClone) --> false
compareinstances
Returns whether objectsa
and b
both reference the same Instance.
Parameters
a
- The first Instance to compare.b
- The second Instance to compare.