• 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: Newest First
  • Oldest First
  • Title
  • Most Reviews
  • Highest Rated
Rating
iNTERFACEWARE
xml.lua
Added by iNTERFACEWARE
Modules
A collection of helpful XML node functions.
dup.lua
Added by iNTERFACEWARE
Modules
Duplicate message filter.
stringutil.lua
Added by iNTERFACEWARE
Modules
A library of helpful extensions to the standard Lua string library.
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.
sha1.lua
Added by iNTERFACEWARE
Modules
A pure Lua-based implementation of the popular SHA-1 hashing function.
retry.lua
Added by iNTERFACEWARE
Modules
A module for retrying operations which might periodically fail like database operations.
mime.lua
Added by iNTERFACEWARE
Modules
Sends MIME-encoded email attachments using the SMTP protocol. A wrapper around net.smtp.send.
iguanaServer.lua
Added by iNTERFACEWARE
Modules
Provides programmatic access to various operations that can be performed on Iguana channels.
hl7.findSegment.lua
Added by iNTERFACEWARE
Modules
A utility for finding any HL7 segment in a parsed HL7 message node tree.
dateparse.lua
Added by iNTERFACEWARE
Modules
A fuzzy date/time parser that is very useful for automatically translating a wide variety of date/time formats.
custom_merge.lua
Added by iNTERFACEWARE
Modules
A customizable database merge method for Iguana 5.5.1 and up.
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.