lapis icon indicating copy to clipboard operation
lapis copied to clipboard

Support for Redis & Mongodb

Open diverted247 opened this issue 12 years ago • 10 comments
trafficstars

diverted247 avatar Oct 24 '13 05:10 diverted247

I already use Lapis with Redis myself, see here (especially model.lua and redismodel.lua).

What would Redis support in Lapis look like? I have a lot of experience with Redis and high-level interfaces for it. Ultimately I think they are a bad idea.

When you use Redis you want to know and control how your data is stored in it, you want to choose the name of the keys, the way you make indices... Moreover if you work like me you will start developing by making direct calls to Redis method from your application code, and later on you will move a lot of logic to Lua scripts that run within Redis. Also, you will probably serialize data, but in what format? JSON, MessagePack, something else? So I think it is better to use a Redis client that stays close to the protocol.

MongoDB is different, it is document-oriented so I think it makes a lot of sense to have some kind of object mapper for it.

catwell avatar Oct 24 '13 08:10 catwell

@catwell While I agree on that redis libs should stay close to protocol I had a look at your model.lua redismodel.lua and I think a few helper modules could have its place within lapis core. Any reason why your repository does not contain the moon source files? Also I would like to comment that it does not seem like you are using the lua-resty-redis library, but some other native lua lib?

torhve avatar Nov 20 '13 12:11 torhve

Hello @torhve,

the reason there is no .moon source is this repository is that there is no .moon source at all, I wrote it in Lua :) I only use MoonScript for configuration and views.

I agree with you about lua-resty-redis. I used redis-lua, the Redis library I usually use in Lua. It's pure Lua so it works, but in OpenResty I should use lua-resty-redis to avoid blocking, and I will switch when I find the time. I just created an issue :)

catwell avatar Nov 20 '13 13:11 catwell

@catwell Ah. I made an assumption about Moon, my bad :-)

torhve avatar Nov 20 '13 13:11 torhve

Hello, I found this issue active but a little old now. Nevertheless, I think it is important to say that exists a MongoDB driver for Lua called luamongo 0.2 which works fine with Lua 5.1. The last version of luamongo is adapted to work with Lua 5.2, so it is not possible to run it with lapis as far as I know. Bests

pakozm avatar Jun 18 '14 07:06 pakozm

Try this library out for mongo: https://github.com/Olivine-Labs/resty-mongol

It's designed to work within openresty.

leafo avatar Jun 18 '14 14:06 leafo

Hey, i am migrating a simple api using mongodb So. i'am starting to build a lapis model for mongodb

You can check https://github.com/CriztianiX/lapis-mongodb Some examples in app.moon, https://github.com/CriztianiX/lapis-mongodb/blob/master/lapis/db/mongodb/model.moon

I'm using https://github.com/isage/lua-resty-moongoo for work within openresty

CriztianiX avatar Dec 28 '16 20:12 CriztianiX

I'm working on something similar for Cassandra/ScyllaDB, but it's a patch to lapis itself. @CriztianiX do you mind if I use your repo as a skeleton to turn Cassandra support into a separate project?

I.e. Could you please add a Copying file and make it liberal ;-)

hengestone avatar Jan 19 '17 21:01 hengestone

Done!!!... Feel you free to use and colaborate if you wish!

CriztianiX avatar Jan 19 '17 21:01 CriztianiX

Thanks, much appreciated!

hengestone avatar Jan 20 '17 00:01 hengestone