lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


In your implementation, all db objects share the same private
attributes, I'm not sure it is what you intended...
Otherwise:

```
local lstore = {}
-- ...
function lstore:open(path, ext)
  local new_db = {
    _path = nil,
    _f = nil,
    _is_locked = false,
    _queue = {},
    _views = {},
    _stored = nil,
    _transact = { runnning = false },
    _data = {}
  }
  setmetatable(new_db, { __index = lstore })
  -- ...
end
```

` lstore:_unlock` code could be improved:

```
function lstore:_unlock()
  self._is_locked = false
  local Q=self._queue
  for i=1,#Q do
    Q[i]()
  end
  self._queue = {} -- let the garbage collector dispose of the old one.
  -- getmetatable(self)._queue = {} -- assuming my assumption above is mistaken.
end
```


-- Pierre-Yves



On Thu, Feb 2, 2012 at 10:44, Fabien Bourgeois <fbourgeois@yaltik.com> wrote:
> I'm glad to announce my first Lua program, lstore.
>
> lstore is just another simple / stupid database for lazy Lua programmers.
> I've decided to store JSON objects rather than Lua tables for several
> reasons :
>
> * Interoperability : the storage file - text as default - can be read,
> edited by any JSON-aware tools
> * Data only : I don't want to store functions, references... just data
> * Coherence : I'll use JSON and JSON-RPC in my projects
>
> lstore is released under MIT license.
> For the moment, there is no rock file. The requirements are DKJSON or CJSON.
>
> The official website can be found at <http://projects.yaltik.net/lstore> .
>
> I've chosen fossil for its simplicity, all-in-one solution to administrate
> small projects, and the pleasant idea of having distributed wiki and bug
> tracker. You can also register yourself on the website.
>
> I've tried to follow the Lua-Users Style Guide page
> <http://lua-users.org/wiki/LuaStyleGuide> and write decent docstrings and
> unittests.
> But it's my firsts Lua code and project : all criticisms are really welcome.
>
> Thanks for reading.
>
> PS : as you see, I'll need to improve my english. I'll work on it.
>