Giter Site home page Giter Site logo

ravener / luvel Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 25 KB

A LevelDB wrapper for LuaJIT and Luvit

Home Page: https://ravener.github.io/luvel

License: MIT License

Lua 100.00%
database ffi ffi-bindings ffi-wrapper key-value leveldb lua luajit luajit-bindings luajit-ffi

luvel's Introduction

Luvel

luvel is a LuaJIT FFI wrapper for leveldb

Install

luvel only runs on LuaJIT and Luvit.

If you are using LuaJIT just copy the luvel.lua file into your project.

If you are using luvit then you may install the lit package:

$ lit install ravener/luvel

Usage

local luvel = require("luvel")
local db = luvel.open("database", { createIfMissing = true })

-- Putting keys
db:put("key", "value")
db:put("another", "two")

-- Getting keys
print(db:get("key"))

-- Iterators
for k, v in pairs(db) do
  print(k, v)
end

-- Close the database.
db:close()

See also the full documentation

TODO

The library is usable, although I'm still cleaning it up and things are bound to change a lot.

Here's a list of things left to do:

  • Snapshots support
  • Support more options
  • More documentation
  • Tests

And more, expect it to be stable after a 1.0.0 release. In the meantime sending feedback regarding the design will help a lot.

License

Released under MIT License

The initial code started as a modification of Codezerker/lua_leveldb but has since evolved into a much higher level wrapper.

luvel's People

Contributors

laminariy avatar ravener avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

laminariy

luvel's Issues

Iterator:key() and Iterator:value()?

Maybe for more flexible use of iterators, one may not always need both key and value so exposing a seperate key function that returns the current key and a value function returning the current value may optimize some large iterators. Maybe they prefer to read the value after checking the key for example.

How is that?

Snapshots

Add support for database snapshots.

Remove db:each and db:newIteratorWith

Functions existed from the original library, I don't think we need these anymore.

db:each is no longer needed due to __pairs

And they were mostly there to make it easy to manage the memory since they clean up after executing user's callback. No longer needed because we have __gc for auto clean up.

Fix __gc

__gc on tables is not supported on Lua 5.1.

Switch the datatypes to use ffi.metatype which allows us to attach a metatable that supports __gc

Read options

Currently wherever a read options object is expected is just a placeholder, no actual options can be passed.

Support these options.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.