mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
refactor(resource/cache): new cache event
Rather than sending a bulk update of cache, trigger different events for each key.
This commit is contained in:
10
resource/cache/client.lua
vendored
10
resource/cache/client.lua
vendored
@@ -24,12 +24,10 @@ function cache:getVehicle()
|
||||
end
|
||||
end
|
||||
|
||||
local update = {}
|
||||
|
||||
function cache:set(key, value)
|
||||
if value ~= self[key] then
|
||||
self[key] = value
|
||||
update[key] = value
|
||||
TriggerEvent(('ox_lib:cache:%s'):format(key), value)
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -38,12 +36,6 @@ CreateThread(function()
|
||||
while true do
|
||||
cache:set('ped', PlayerPedId())
|
||||
cache:getVehicle()
|
||||
|
||||
if next(update) then
|
||||
TriggerEvent('ox_lib:updateCache', update)
|
||||
table.wipe(update)
|
||||
end
|
||||
|
||||
Wait(100)
|
||||
end
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user