Skip to main content

Simple ActiveRecord pattern for Redis

Project description

# Example:

from active_redis import ActiveRedis, ActiveRedisModel, UUIDGenerator

class Movie(ActiveRedisModel):
stored_attrs = ['title', 'year', 'author']

def __init__(self, uuid, title, year, author):
self.uuid = uuid
self.title, self.year, = title, year, author

if __name__ == '__main__':
ActiveRedis.config = {
'connexion': {'db': 3},
'namespace_prefix': 'mycinema'

assert Movie.delete_all()
assert 0, Movie.count()

topgun = Movie(UUIDGenerator.generate(), 'TopGun', 1987, 'Tony S.')

titanic = Movie(UUIDGenerator.generate(), 'Titanic', 1997, 'James C.')

topgun.update_attr('title', 'Top Gun')
assert 'Top Gun', Movie.find(topgun.uuid).title

assert 2, Movie.count()
assert 2, len(Movie.find_all())

m = Movie.find(topgun.uuid)

assert 1, Movie.count()
assert 1, len(Movie.find_all())

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for active_redis, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size active_redis-0.0.2.macosx-10.4-x86_64.exe (67.1 kB) File type Windows Installer Python version any Upload date Hashes View
Filename, size active_redis-0.0.2.tar.gz (2.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page