跳转到主要内容

Riak的Memcached-like接口

项目描述

Build Status Coverage Status PyPI version

一个类似Memcached的接口,用于Riak HTTP客户端。 阅读文档

安装

从PyPI

pip install riakcached

从Git

git clone git://github.com/brettlangdon/riakcached.git
cd ./riakcached
pip install -r requirements.txt
python setup.py install

使用

基本使用

from riakcached.clients import RiakClient

client = RiakClient("my_bucket")

client.set("hello", "world")
print client.get("hello")
# 'hello'

client.delete("hello")
print client.get("hello")
# None

values = {
    "hello": "world",
    "foo": "bar",
}
client.set_many(values)

keys = ["hello", "foo", "test"]
print client.get_many(keys)
# {'foo': 'bar', 'hello': 'world'}

client.close()

连接池设置

from riakcached.clients import RiakClient
from riakcached.pools import Urllib3Pool

pool = Urllib3Pool(base_url="http://my-host.com:8098/", timeout=1)
client = RiakClient("my_bucket", pool=pool)

client.get("foo")

自定义连接池

from riakcached.clients import RiakClient
from riakcache.pools import Pool

class CustomPool(Pool):
    __slots__ = ["connection"]

    def connect(self):
        self.connection = make_a_connection()

    def close(self):
        if self.connection:
            close_connection(self.connection)

    def request(self, method, url, body=None, headers=None):
        results = make_request(self.connection, method, url, body, headers, timeout=self.timeout)
        return results.status, results.data, results.headers


custom_pool = CustomPool(base_url="http://my-host.com:8098", timeout=1)
client = RiakClient("my_bucket", pool=pool)

线程客户端

存在一个继承自riakcached.clients.RiakClientriakcached.clients.ThreadedRiakClient,它使用线程来尝试并行化调用get_manyset_manydelete_many

文档

文档位于此存储库的/docs目录中,对于代码库应该是相当完整的。

构建文档

git clone git://github.com/brettlangdon/riakcached.git
cd riakcached
pip install -r docs-requirements.txt
cd ./docs
make html

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

riakcached-0.1.0.zip (10.7 kB 查看哈希)

上传时间: 源代码

riakcached-0.1.0.tar.gz (6.9 kB 查看哈希)

上传时间 源代码

支持者