cache.invalidate
Removes an instance from the reference cache.
Syntax
cache.invalidate(instance: Instance) -> ()Parameters
| Parameter | Type | Description |
|---|---|---|
instance | Instance | The instance to invalidate |
Returns
This function does not return a value.
Description
cache.invalidate removes an instance from the cache. A later lookup may return a different reference to the same instance.
Example
local folder = Instance.new("Folder")
folder.Name = "CacheInvalidateExample"
folder.Parent = workspace
local firstReference = folder
-- Invalidate the cache
cache.invalidate(firstReference)
-- Looking up the same instance again may return a new reference
local secondReference = workspace:FindFirstChild("CacheInvalidateExample")
print(rawequal(firstReference, secondReference)) -- false
print(compareinstances(firstReference, secondReference)) -- true
firstReference:Destroy()Notes
- Existing references remain usable
- Use
compareinstancesto compare references after invalidating the cache
Related Functions
cache.replace- Replace cached instancecache.iscached- Check if cached