Skip to content

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 ​

KeyContextValue
cache.gameshared'gta5'
cache.resourcesharedCurrent resource name
cache.playerIdclientPlayerId()
cache.serverIdclientServer-side source of the local player
cache.pedclientAutomatically 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