MangoDB?!不是MongoDb!

MangoDB 宣称自己是比MongoDB更可靠更快速的版本,而且只有 30 行代码。

下面是来自 MangoDB 首页上的介绍:

MangoDB 是最快的数据库之一,它允许你存放任意类型的数据,没有任何 IO 瓶颈。如果你熟悉 MongoDB,那么你使用 MangoDB 会很顺手,,你无需任何操作就可立即映射已有的数据到一个全新的自动 SHARTING 算法。

关键是该软件只有 30 行代码:

from gevent.server import StreamServerimport osdef mangodb(socket, address):socket.sendall(‘HELLO\r\n’)client = socket.makefile()output = open(‘/dev/null’, ‘w’)while 1:line = client.readline()if not line:breakcmd_bits = line.split(‘ ‘, 1)cmd = cmd_bits[0]if cmd == ‘BYE’:breakif len(cmd_bits) > 1:output.write(cmd_bits[1])if os.environ.get(‘MANGODB_DURABLE’, False):output.flush()os.fsync(output.fileno())client.write(‘OK’ + os.urandom(1024).encode(‘string-escape’) + ‘\r\n’)client.flush()if __name__ == ‘__main__’:server = StreamServer((‘0.0.0.0’, 27017), mangodb)print (‘Starting MangoDB on port 27017’)server.serve_forever()Getting Started

先安装gevent:

easy_install -U gevent

然后运行服务器:

python server.py

用你的MongoDB客户端连接到本机的27017端口看看?

你可以得到和MongoDB一样的功能,但是它更快!

VIA

大多数人想要改造这个世界,但却罕有人想改造自己。

MangoDB?!不是MongoDb!

相关文章:

你感兴趣的文章:

标签云: