[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [ANN] lua-tokyotyrant
- From: Phoenix Sol <phoenix@...>
- Date: Fri, 25 Dec 2009 12:29:16 -0600
Because a little interest was shown before about using Tokyo Tyrant
with Lua, I will report to the list what evil I have wrought.
My earlier attempt, a pure Lua implementation of the Tyrant protocol,
has been abandoned in favor of a binding to Mikio's tcrdb interface.
It was some of my first Lua code, and sat untested and unloved for
several months. After looking back over it, and even giving it a quick
first pass of an overhaul, I felt my heart fill with mistrust and
contempt for the accursed thing.
A C binding to Mikio's remote database interface inspires in me both
confidence and relief. Mikio is a living god. My humble binding bows
before his great works.
I'm still a novice C programmer; I'd *much appreciate* your wise
review, and gentle feedback.
It's fairly complete, except for the Table Extension (which I may
someday get around to doing). Also, there are a few things that
haven't been tested yet, due to laziness and holiday cheer, etc.
(copy, restore, setmaster, optimize, ext). A couple of methods also
take timestamps in microseconds, and I've yet to mess with those (they
wait...).
The revelry goes something like this...
--( typed directly into email message x_x )--
local tyr = require 'tokyotyrant'
local db = tyr.open() -- connect to default host and port: 'localhost', 1978
--local my_other_db = tyr.open('myhost', 9966)
db:put( 'cthulhu', 'fhtagn' ) -- tcrdbput
db:put{ cthulhu_author='Lovecraft', cthulhu_title='The Call of
Cthulhu', cthulhu_date=1928, cthulhu_genre='awesome' } -- tcrdbmisc
local keys = db:fwmkeys('cthulhu_') -- tcrdbfwmkeys;
'forward matching keys'
for k in db:keys() do print(k), db:get(k) end -- iterate over all keys
=db:get( 'cthulhu' ) -- tcrdbget
=db:get( keys ) -- tcrdbmisc
=db:size() -- size of database
=db:rnum() -- number of records
=#db -- number of records
db:out( keys ) -- tcrdbmisc
db:out( 'cthulhu' ) -- tcrdbout
db:vanish() -- destroy everything
db:close()
db = nil
http://github.com/phoenixsol/lua-tokyotyrant