Redis dependency for nameko services
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
.travis.yml
LICENSE Initial commit Jul 25, 2015
MANIFEST.in exlude tests from package May 29, 2016
README.md
contributors.txt Amend README and add contributors. Mar 27, 2017
nameko_redis.py
setup.py Update setup.py Mar 28, 2017

README.md

nameko-redis

PyPI version Build Status

Redis dependency for nameko services

Installation

pip install nameko-redis

Usage

from nameko.rpc import rpc
from nameko_redis import Redis


class MyService(object):
    name = "my_service"

    redis = Redis('development')

    @rpc
    def hello(self, name):
        self.redis.set("foo", name)
        return "Hello, {}!".format(name)

    @rpc
    def bye(self):
        name = self.redis.get("foo")
        return "Bye, {}!".format(name)

To specify redis connection string you will need a config

AMQP_URI: 'amqp://guest:guest@localhost'
REDIS_URIS:
 development: 'redis://localhost:6379/0'

You can also pass extra options to the class, like this:

class MyOtherService(object):
    name = "my_other_service"

    redis = Redis('development', decode_responses=False, encoding='utf-8')

    ...