Permalink
Browse files

0.1.0 commit

  • Loading branch information...
srinikom committed Nov 22, 2011
0 parents commit b4783f09abc9e7041f57ad00cca4256dc4125775
@@ -0,0 +1,115 @@
+h2. leveldb-server
+Async leveldb-server based on zeromq.
+More info about leveldb
+More info about zeromq
+
+h3. License
+New BSD license. Please see license.txt for more details
+
+h2. Features
+
+h3. leveldb features
+* Very simple key-value storage
+* Data is sorted by key - allows @ range @ queries
+* Data is automatically compressed
+* Can act as presistant cache
+* For safebox it replaced memcached+mysql
+* @cp level.db backup.db@ for backup
+
+h3. leveldb-server features
+* Networking/wiring from @ zeromq @ messaging library
+* Async server for scalability and capacity
+* Sync client for easy coding
+
+h3. leveldb-client features
+* python client
+* easy to get multiple language bindings. See here for zmq client library http://www.zeromq.org/bindings:_start
+
+<pre>
+>>> db.put("k3", "v3")
+'True'
+>>> db.get("k3")
+'v3'
+>>> db.range()
+'[{"k1": "v1"}, {"k2": "v2"}, {"k3": "v3"}]'
+>>> db.delete('k1')
+>>>
+</pre>
+
+Will be adding high availability, replication and autosharding using the same zeromq framework.
+
+h3. Dependencies
+<pre>
+python
+zmq
+pyzmq
+leveldb
+pyleveldb
+</pre>
+
+h2. Getting Started
+
+h3. Installing zeromq
+
+<pre>
+wget http://download.zeromq.org/zeromq-2.1.10.tar.gz
+tar xvfz zeromq-2.1.10.tar.gz
+cd zeromq-2.1.10
+sudo ./configure
+sudo make
+sudo make install
+</pre>
+
+h3. Installing pyzmq
+<pre>
+wget https://github.com/zeromq/pyzmq/downloads/pyzmq-2.1.10.tar.gz
+tar xvfz pyzmq-2.1.10.tar.gz
+cd pyzmq-2.1.10/
+sudo python setup.py configure --zmq=/usr/local/lib/
+sudo python setup.py install
+</pre>
+
+h3. Installing leveldb and pyleveldb
+<pre>
+svn checkout http://py-leveldb.googlecode.com/svn/trunk/ py-leveldb-read-only
+cd py-leveldb-read-only
+sudo compile_leveldb.sh
+sudo python setup.py install
+</pre>
+
+h3. Starting the leveldb-server
+<pre>
+> python leveldb-server.py -h
+Usage: leveldb-server.py
+ -p [port and host settings] Default: tcp://127.0.0.1:5147
+ -f [database file name] Default: level.db
+
+leveldb-server
+
+Options:
+ --version show program's version number and exit
+ -h, --help show this help message and exit
+ -p HOST, --host=HOST
+ -d DBFILE, --dbfile=DBFILE
+> python leveldb-server.py
+</pre>
+
+h3. Using the leveldb-client-py
+<pre>
+> sudo python setup.py install
+> python
+>>> from leveldbClient import database
+>>> db = database.leveldb()
+>>> db.get("Key")
+>>> db.put("K", "V")
+>>> db.range()
+>>> db.range(start, end)
+>>> db.delete("K")
+</pre>
+
+h2. Backing up the database
+<pre>
+cp -rpf level.db backup.db
+</pre>
+
+
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+#Copyright (c) 2011 Fabula Solutions. All rights reserved.
+#Use of this source code is governed by a BSD-style license that can be
+#found in the license.txt file.
+
+"""The client for leveldb-server."""
+
+version = "0.1.0"
+version_info = (0, 1, 0)
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+#Copyright (c) 2011 Fabula Solutions. All rights reserved.
+#Use of this source code is governed by a BSD-style license that can be
+#found in the license.txt file.
+
+# leveldb client
+import zmq
+import threading
+import time
+import json
+
+class leveldb(object):
+ """leveldb client"""
+ def __init__(self, host="tcp://127.0.0.1:5147", timeout=10*1000):
+ self.host = host
+ self.timeout = timeout
+ self.connect()
+
+ def connect(self):
+ self.context = zmq.Context()
+ self.socket = self.context.socket(zmq.XREQ)
+ self.socket.connect(self.host)
+
+ def get(self, key):
+ self.socket.send_multipart(['get', json.dumps(key)])
+ return self.socket.recv_multipart()[0]
+
+ def put(self, key, value):
+ self.socket.send_multipart(['put', json.dumps([key, value])])
+ return self.socket.recv_multipart()[0]
+
+ def delete(self, key):
+ self.socket.send_multipart(['delete', json.dumps(key)])
+ return self.socket.recv_multipart()[0]
+
+ def range(self, start=None, end=None):
+ self.socket.send_multipart(['range', json.dumps([start, end])])
+ return self.socket.recv_multipart()[0]
+
+ def close(self):
+ self.socket.close()
+ self.context.term()
+
Binary file not shown.
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+#Copyright (c) 2011 Fabula Solutions. All rights reserved.
+#Use of this source code is governed by a BSD-style license that can be
+#found in the license.txt file.
+
+"""The client for leveldb-server."""
+
+version = "0.1.0"
+version_info = (0, 1, 0)
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+#Copyright (c) 2011 Fabula Solutions. All rights reserved.
+#Use of this source code is governed by a BSD-style license that can be
+#found in the license.txt file.
+
+# leveldb client
+import zmq
+import threading
+import time
+import json
+
+class leveldb(object):
+ """leveldb client"""
+ def __init__(self, host="tcp://127.0.0.1:5147", timeout=10*1000):
+ self.host = host
+ self.timeout = timeout
+ self.connect()
+
+ def connect(self):
+ self.context = zmq.Context()
+ self.socket = self.context.socket(zmq.XREQ)
+ self.socket.connect(self.host)
+
+ def get(self, key):
+ self.socket.send_multipart(['get', json.dumps(key)])
+ return self.socket.recv_multipart()[0]
+
+ def put(self, key, value):
+ self.socket.send_multipart(['put', json.dumps([key, value])])
+ return self.socket.recv_multipart()[0]
+
+ def delete(self, key):
+ self.socket.send_multipart(['delete', json.dumps(key)])
+ return self.socket.recv_multipart()[0]
+
+ def range(self, start=None, end=None):
+ self.socket.send_multipart(['range', json.dumps([start, end])])
+ return self.socket.recv_multipart()[0]
+
+ def close(self):
+ self.socket.close()
+ self.context.term()
+
@@ -0,0 +1,10 @@
+Metadata-Version: 1.0
+Name: leveldb-server-client
+Version: 0.1.0
+Summary: client for leveldb-server
+Home-page: https://github.com/srinikom/leveldb-server
+Author: Srini
+Author-email: srini@fabulasolutions.com
+License: BSD
+Description: UNKNOWN
+Platform: UNKNOWN
@@ -0,0 +1,7 @@
+setup.py
+leveldbClient/__init__.py
+leveldbClient/database.py
+leveldb_server_client.egg-info/PKG-INFO
+leveldb_server_client.egg-info/SOURCES.txt
+leveldb_server_client.egg-info/dependency_links.txt
+leveldb_server_client.egg-info/top_level.txt
@@ -0,0 +1 @@
+leveldbClient
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+#Copyright (c) 2011 Fabula Solutions. All rights reserved.
+#Use of this source code is governed by a BSD-style license that can be
+#found in the license.txt file.
+
+import distutils.core
+import sys
+# Importing setuptools adds some features like "setup.py develop", but
+# it's optional so swallow the error if it's not there.
+try:
+ import setuptools
+except ImportError:
+ pass
+
+kwargs = {}
+
+version = "0.1.0"
+
+distutils.core.setup(
+ name="leveldb-server client",
+ version=version,
+ packages = ["leveldbClient"],
+ author="Srini",
+ author_email="srini@fabulasolutions.com",
+ url="https://github.com/srinikom/leveldb-server",
+ license="BSD",
+ description="client for leveldb-server",
+ **kwargs
+)
Oops, something went wrong.

0 comments on commit b4783f0

Please sign in to comment.