User Tools

Site Tools


key-value_storage

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
key-value_storage [2019/01/09 11:03] akuzmukkey-value_storage [2021/07/22 07:32] (current) – ↷ Links adapted because of a move operation atolstov
Line 1: Line 1:
 ====== Key-value storage ====== ====== Key-value storage ======
-Key-value storage is a simple database that you can use to store any data using your scripts. It is useful when you need to save settings, parameters, counters, flags, etc. Values are being stored in backups as well. So they will be restored on backup restore,+Key-value storage is a simple database that you can use to store any data using your scripts. It is useful when you need to save settings, parameters, counters, flags, etc. Values are being stored in backups as well. So they will be restored on backup restore.
  
 This storage was added in WebHMI version 3.4. This storage was added in WebHMI version 3.4.
Line 10: Line 10:
 ==== Set(key, value) ==== ==== Set(key, value) ====
  
-The Set function saves value into key-value storage. **key** is an identified of value. **value** is a data that you want to save to storage.+The Set function saves value into key-value storage. **key** is an identifier of value. **value** is a data that you want to save to storage.
  
 Function returns true on success and false if any error occurred. Function returns true on success and false if any error occurred.
Line 18: Line 18:
  
 function main (userId) function main (userId)
-    if (!Set("my permanent variable", 42)) then+    if (Set("my permanent variable", 42) == false) then
        ERROR("Can't save data to storage.");        ERROR("Can't save data to storage.");
     end     end
Line 41: Line 41:
 ==== Save tables into storage ==== ==== Save tables into storage ====
  
-You can use [[lua_cjson]] library to encode tables into strings. This will allow save them into storage.+You can use [[lua:lua_cjson]] library to encode tables into strings. This will allow save them into storage.
  
 Here is example: Here is example:
key-value_storage.1547031804.txt.gz · Last modified: 2019/01/09 11:03 by akuzmuk

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki