---
title: "cache.replace"
description: "Maps the old underlying instance key to the new wrapper in the cache."
---

```lua
cache.replace(old: Instance, new: Instance): ()
```

---

## Aliases

None.

---

## Arguments

<ParamField body="old" type="Instance" required>
  The Instance whose cached wrapper entry is replaced.
</ParamField>

<ParamField body="new" type="Instance" required>
  The replacement Instance wrapper.
</ParamField>

---

## Returns

This function returns no values.

Changes future wrapper lookup; does not replace objects in the DataModel or change existing references.

---

## Example

```lua
local a, b = Instance.new("Part"), Instance.new("Part")
cache.replace(a, b)
cache.invalidate(a)
cache.validate(a)
a:Destroy()
b:Destroy()
```
