Welcome to Redis Protocol’s documentation!

Contents:

Redis Protocol

https://badge.fury.io/py/redis_protocol.png https://travis-ci.org/youngking/redis_protocol.png?branch=master https://pypip.in/d/redis_protocol/badge.png

Redis Protocol implemented by python

Usage

This is the protocol implemented followed by redis protocol specification. I had used it in my redis_proxy project.

>>> from redis_protocol import decode, encode
>>> encode("ping")  # encode a request
... '*1\r\n$4\r\nping\r\n'
>>> decode('*1\r\n$4\r\nping\r\n') # decode a request body
... ["ping"]
>>> decode("$6\r\nfoobar\r\n")  # decode a response
... "foobar"

parse redis protocol stream

parse redis protocol stream to redis commands,such as redis pipeline requests or raw responses.

>>> from redis_protocol import parse_stream
>>> data = '*3\r\n$3\r\nSET\r\n$15\r\nmemtier-8232902\r\n$2\r\nxx\r\n' \
       '*3\r\n$3\r\nSET\r\n$15\r\nmemtier-8232902\r\n$2\r\nxx\r\n' \
       '*3\r\n$3\r\nSET\r\n$15\r\nmemtier-7630684\r\n$3\r\nAAA\r\n'
>>> print(parse_stream(data))
... ['SET memtier-8232902 xx', 'SET memtier-8232902 xx', 'SET memtier-7630684 AAA']

Installation

At the command line:

$ easy_install redis_protocol

Or, if you have virtualenvwrapper installed:

$ mkvirtualenv redis_protocol
$ pip install redis_protocol

Usage

To use Redis Protocol in a project:

import redis_protocol

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions

Report Bugs

Report bugs at https://github.com/youngking/redis_protocol/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your local setup that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.

Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.

Implement Features

Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implement it.

Write Documentation

Redis Protocol could always use more documentation, whether as part of the official Redis Protocol docs, in docstrings, or even on the web in blog posts, articles, and such.

Submit Feedback

The best way to send feedback is to file an issue at https://github.com/youngking/redis_protocol/issues.

If you are proposing a feature:

  • Explain in detail how it would work.
  • Keep the scope as narrow as possible, to make it easier to implement.
  • Remember that this is a volunteer-driven project, and that contributions are welcome :)

Get Started!

Ready to contribute? Here’s how to set up redis_protocol for local development.

  1. Fork the redis_protocol repo on GitHub.

  2. Clone your fork locally:

    $ git clone git@github.com:your_name_here/redis_protocol.git
    
  3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:

    $ mkvirtualenv redis_protocol
    $ cd redis_protocol/
    $ python setup.py develop
    
  4. Create a branch for local development:

    $ git checkout -b name-of-your-bugfix-or-feature
    
Now you can make your changes locally.

5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:

  $ flake8 redis_protocol tests
        $ python setup.py test
  $ tox

To get flake8 and tox, just pip install them into your virtualenv.
  1. Commit your changes and push your branch to GitHub:

    $ git add .
    $ git commit -m "Your detailed description of your changes."
    $ git push origin name-of-your-bugfix-or-feature
    
  2. Submit a pull request through the GitHub website.

Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

  1. The pull request should include tests.
  2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
  3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check https://travis-ci.org/youngking/redis_protocol/pull_requests and make sure that the tests pass for all supported Python versions.

Tips

To run a subset of tests:

$ python -m unittest tests.test_redis_protocol

Credits

Development Lead

Contributors

None yet. Why not be the first?

History

0.0.2 (2015-02-12)

  • add parse redis protocol stream

0.0.1 (2013-08-11)

  • First release on PyPI.

Indices and tables