[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: persistant tables
- From: Asko Kauppi <asko.kauppi@...>
- Date: Mon, 21 Feb 2005 23:30:34 +0200
A pre-information about a feature in upcoming LuaX that might be
beneficial for others, too.
Persistant tables (no trademark applied :) is a way to make Lua tables
that sync automatically to a disk image. It works as a module, using
SQLite3, but that is just an implementation detail.
The API:
-----
-- Opens a persistant table to work with (creates the database file if
not there).
--
-- 'section' is an optional string, allowing to have several,
independent tables
-- of data within the one filename.
--
[per_obj] [,err_str]= open( fname_str [,section_str] )
-- Closing the handle is not really required, GC will do it
automatically.
--
void= close( per_obj )
The 'per_obj' value can be used as any regular table, writing numbers,
strings, booleans and/or tables to it. Tables are written on disk as a
transaction, supposedly guaranteeing data integrity. Reading data is
fast, writing _can_ be fast (if syncing is turned off).
Iterating over the contents is possible in LuaX (but not in plain Lua)
using the regular 'pairs' and 'ipairs' functions.
-ak