This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Object-Key Mapper for Redis

If you’ve used redis on python, you’ve had to deal with redis keys. Sometimes, lots of redis keys. With so many keys, it’s easy to make mistakes, especially since keys are just strings. I built ok so that I didn’t have to work with strings for redis keys.

Here’s how you use it:

import ok
import redis


class User(ok.Key):
    fields = ['timeline', 'followers', 'following']


# Get user mixxorz' timeline
r = redis.StrictRedis()
r.zrevrange(User('mixxorz').timeline, 0, 50)
# ZREVRANGE User:mixxorz:timeline 0 50

Managing your keys just became a lot less fragile.

Installation

Install it from pypi

$ pip install ok-redis

Usage

Access fields.

class User(ok.Key):
    fields = ['timeline', 'followers', 'following']


print(User('mixxorz').timeline)
# User:mixxorz:timeline

Chain keys.

class City(ok.Key):
    fields = ['tweets_hll']


class Country(ok.Key):
    subkeys = [City]


print(Country('PH').City('Manila').tweets_hll)
# Country:PH:City:Manila:tweets

Subkeys can be an absolute or relative path to a key.

# mod_one.py
class Refer(Key):
    fields = ['elements']


# mod_two.py
class Parent(Key):
    subkeys = ['..mod_one.Refer']


print(Parent('foo').Refer('bar').elements)
# Parent:foo:Refer:bar:elements

The string representation of a Key instance is the key, so you can use it like this:

class User(ok.Key):
    pass


r.get(User('mixxorz'))

But you can also access the key explicitly.

User('mixxorz').key
# >>> User:mixxorz

IDs are optional.

class User(ok.Key):
    fields = ['rankings']


print(User().rankings)
# User:rankings

IDs don’t have to be strings

class User(ok.Key)
    pass

print(User(123))
# User:123

You can change the string used for the key.

class Facebook(ok.Key):
    fields = ['all_posts']
    class_key = 'fb'


print(Facebook().all_posts)
# fb:all_posts

License

MIT

Release History

Release History

0.1.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
ok-redis-0.1.2.tar.gz (4.1 kB) Copy SHA256 Checksum SHA256 Source Jul 28, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting