:GetCached
Retrieves data instantly from the client's local cache for a realKey that has been previously received via :Request() or :Listen().
This function is synchronous and does not yield or perform any network requests, making it the most performant way to access data you know the client already has.
DataReplicator:GetCached(realKey: string)
realKey: stringThe original data key.
any | nil - The current cached data, or nil if no data for that key exists in the cache.
-- Sometime after requesting or listening to player health...
local function onPlayerTakeDamage()
-- Instantly get the current health from the local cache.
local currentHealth = DataReplicator:GetCached("PlayerData_12345.Health")
if currentHealth then
-- Use the cached health value for immediate UI feedback.
updateHealthBar(currentHealth)
end
endLast updated