Lua脚本中的一个NoSQL数据库:Tarantool

jopen 10年前

介绍

Tarantool是一个NoSQL数据库,运行在Lua编程语言中。 它利用了Node.JS强大的网络编程功能,数据存储利用了Redis持久化功能。

特性

  • a drop-in replacement for Lua 5.1, based on LuaJIT 2.0; simply use #!/usr/bin/tarantool instead of #!/usr/bin/lua in your script,
  • Lua packages for non-blocking I/O, fibers and HTTP,
  • MsgPack data format and MsgPack based client-server protocol,
  • two data engines: 100% in-memory with optional persistence and a 2-level disk-based B-tree, to use with large data sets,
  • secondary key and index iterators support,
  • asynchronous master-master replication,
  • authentication and access control.

示例代码:

#!/usr/bin/env tarantool    box.cfg{}  hosts = box.space.hosts  if not hosts then      hosts = box.schema.create_space('hosts')      hosts:create_index('primary', { parts = {1, 'STR'} })  end    local function handler(self)      local host = self.req.peer.host      local response = {          host = host;          counter = hosts:inc(host);      }      self:render({ json = response })  end    httpd = require('http.server')  server = httpd.new('127.0.0.1', 8080)  server:route({ path = '/' }, handler)  server:start()

    项目主页:http://www.open-open.com/lib/view/home/1406259221585