This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

lua api
#2
You can create a scheduled script to write data to CSV and use storage lists for storing temporary entries. This will solve the issue with writing in parallel.

This code adds an entry to the end of the list named mylist. Note that the value can only be a string, but not a Lua table.
Code:
key = 'mylist'
value = 'some string value'
storage.exec('rpush', key, value)

This code reads all entries from the list named mylist. All read entries are removed. New entries entries that can be added when the script is already running are not affected.
Code:
key = 'mylist'
values = storage.exec('lrange', key, 0, -1)

if type(values) == 'table' then
  for _, value in ipairs(values) do
    -- do something with value
  end

  -- remove read entries from the list
  storage.exec('ltrim', key, #values, -1)
end
Reply


Messages In This Thread
lua api - by mellotron - 05.08.2023, 08:59
RE: lua api - by admin - 07.08.2023, 08:22
RE: lua api - by mellotron - 13.08.2023, 18:13
RE: lua api - by mellotron - 24.08.2023, 07:18
RE: lua api - by admin - 24.08.2023, 08:13
RE: lua api - by mellotron - 24.08.2023, 09:17

Forum Jump: