cache — Global Cache Object
A reactive cache table available globally. Reading undefined keys triggers an auto-fetch from the st_libs server export.
Built-in keys
| Key | Context | Value |
|---|---|---|
cache.game | shared | 'gta5' |
cache.resource | shared | Current resource name |
cache.playerId | client | PlayerId() |
cache.serverId | client | Server-side source of the local player |
cache.ped | client | Automatically updated local player ped handle |
Usage
lua
-- Read — auto-resolves from st_libs if not cached
local ped = cache.ped
-- Write with optional expiry
cache('myKey', function()
return computeExpensiveValue()
end, 5000) -- expires after 5000ms