• Iguana 6
  • Previous Versions
  • API
  • Sample Code
  • Training
  • Create a Ticket
iNTERFACEWARE Help Center
  • Iguana 6
  • Previous Versions
  • API
  • Sample Code
  • Training
  • Create a Ticket

Code Repository

Home›Code Repository›store2.lua
Modules

store2.lua

Verified Featured
Added by iNTERFACEWARE

Provides a simple interface to store key/value pairs in a persistent storage mechanism.

Source Code

https://github.com/interfaceware/iguana-tools/blob/master/shared/store2.lua

Description
Provides a simple interface to store key/value pairs in a persistent storage mechanism.
Usage Details

The store2.lua module contains a simple interface to store key/value pairs in a persistent storage mechanism. Simply put, if you want to store and/or retrieve information across interfaces cross-message; this might be the module to do it.

Under the hood this module creates a SQLite database called ‘store.db’ in the Iguana working directory, which has a table called “store”, which has the name=value pairs. However you don’t need to know this, just create a store module (using the code above) and it will all work automatically.

How to use store.lua:

  • Add it to your shared modules in any Translator project.
  • Add store2 = require 'store.lua' at the top of your script.
  • Use store.connect() to specify the database to use to store data.
  • Use store.put() and store.get() to store and get information respectively.
-- This is the new version of store which allows one translator to have multiple stores
-- iNTERFACEWARE recommends this for newer interface code.  It is convenient to be able to
-- have independent stores for different purposes.

-- This module stores the data in SQLite data base file given in the store2.connect function.
-- By default this goes into the working directory of the Iguana instance.

store2 = require 'store2'

function main()
   local MyStore = store2.connect("store2.db")
   MyStore:put("life", "can be fun")
   MyStore:get("life")
   -- Query all the stored keys
   MyStore:info()
   
   -- Store multiple values
   MyStore:reset() -- clear the store first
   MyStore:put('Larry', 'The ')
   MyStore:put('Curly', 'three')
   MyStore:put('Moe', 'Stooges')
   
   -- check state - returns all stored data
   MyStore:info() --> table node tree with 3 rows 
   
      
   -- Here we create a store which is unique to this translator
   -- by naming it after the GUID of this translator.
   local LocalChannelStore = store2.connect(iguana.project.guid())   
   LocalChannelStore:put("life", "can be interesting")
   
   -- See two independent stores?
   LocalChannelStore:get("life")
   MyStore:get("life")
   
   -- We can reset stores which clears them
   trace(#MyStore:info())
   MyStore:reset()
   trace(#MyStore:info())
   -- Or we can delete them entirely.
   -- os.fs.stat allows us to test for the existance of the
   -- underlying database file.
   local DbFile = iguana.workingDir()..MyStore.name
   os.fs.stat(DbFile)
   MyStore:delete()
   os.fs.stat(DbFile)
   LocalChannelStore:delete()
end
More Information
Store Name=Value Keys
Bookmark
  • Reviews
  • Related Listings
Filter
Sort by: Newest First
  • Oldest First
  • Rating
  • Helpfulness
Write a Review
Rating
Keyword
Filter
Sort by: Title
  • Newest First
  • Oldest First
  • Most Reviews
  • Highest Rated
Rating
iNTERFACEWARE
sha1.lua
Added by iNTERFACEWARE
Modules
A pure Lua-based implementation of the popular SHA-1 hashing function.
sqlite.lua
Added by iNTERFACEWARE
Modules
A module to create a SQLite database and generate the tables specified in a VMD
store.lua
Added by iNTERFACEWARE
Modules
The "original" store module: Allows you to store key/value pairs in a persistent storage mechanism. We recommend using the new store2 module instead.
stream.lua
Added by iNTERFACEWARE
Modules
This module performs basic stream processing, read, write, save to file, convert to text etc.
stringutil.lua
Added by iNTERFACEWARE
Modules
A library of helpful extensions to the standard Lua string library.
test_all.lua
Added by iNTERFACEWARE
Modules
Test a script against all the sample messages loaded for the component
throttle.lua
Added by iNTERFACEWARE
Modules
Throttle a process during peak hours, by slowing down the code.
throttleDB.lua
Added by iNTERFACEWARE
Modules
Throttle database access by reducing the number of inserts during peak hours
urlcode.lua
Added by iNTERFACEWARE
Modules
A module for parsing URL encoded GET/POST sequences
validate.lua
Added by iNTERFACEWARE
Modules
A template module for testing HL7 message conformance, you will need to extend it to match your requirements
xml.lua
Added by iNTERFACEWARE
Modules
A collection of helpful XML node functions.
Showing 21 - 31 of 31 results
«12»

Topics

  • expandGetting Started
  • expandAdministration
    • expandInstallation
    • expandLicensing
    • expandUpgrades
    • expandDeployment
    • expandConfiguration Management
      • expandCustom Configuration
    • expandBackup and Restore
    • expandSecurity
      • expandHIPAA Compliance
    • expandTroubleshooting
  • expandDeveloping Interfaces
    • expandArchitecture
    • expandInterfaces
      • expandHL7
      • expandDatabase
        • expandConnect
      • expandWeb Services
      • expandCDA
      • expandX12
      • expandOther Interfaces
      • expandUtilities
    • expandRepositories
      • expandBuiltin Repositories
        • expandIguana Upgrade
        • expandIguana Tutorials
        • expandIguana Tools
        • expandIguana Protocols
        • expandIguana Files
        • expandIguana Date/Time
        • expandIguana Webservices
        • expandIguana Excel
      • expandRemote Repositories
      • expandCS Team Repositories
        • expandIguana Channels
    • expandSample Code
      • expandModules
      • expandUsing built-in functions
      • expandWorking with XML
    • expandLua Programming
    • expandPerformance
  • expandFAQs and TIPs
    • expandFrequently Asked Questions
      • expandInstalls and Upgrades
      • expandWeb Services
      • expandConfiguration
      • expandChannels
      • expandTranslator
      • expandOther
      • expandDatabase
      • expandAdministration
      • expandLogs
      • expandChameleon
    • expandTips
      • expandChannels
      • expandChameleon
      • expandWeb Services
      • expandSecurity
      • expandProgramming
      • expandOther
      • expandAdministration
  • expandReference
    • expandIguana Enterprise and Professional
    • expandProgram Settings
    • expandChannel Settings
    • expandDashboard
    • expandChannels
    • expandTranslator
    • expandLogs
      • expandLog Encryption
    • expandHTTP API
    • expandCDA API
    • expandError Messages
    • expandChameleon
    • expandIguana Change Log

Other Links

  • Training Center
  • News & Announcements
  • iNTERFACEWARE Blog
  • Older Documention (IGUANA v4 & Chameleon)
Copyright © iNTERFACEWARE Inc.