Tarantool嵌入式 NoSQL 数据库
Tarantool 是一个用 Lua 语言编写的嵌入式 NoSQL 数据库,可以直接在 Lua 程序中运行。合并了 Node.js 的强大网络编程和 Redis 数据持久。
示例代码:
#!/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()
评论