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, self.author = 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.')
assert topgun.save()

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

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)
m.delete()

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.

Source Distribution

active_redis-0.0.2.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

active_redis-0.0.2.macosx-10.4-x86_64.exe (67.1 kB view details)

Uploaded Source

File details

Details for the file active_redis-0.0.2.tar.gz.

File metadata

File hashes

Hashes for active_redis-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ed8e808c1ed73f918f1db00c0ca0f17c340d6b55b99215c0933fa8a651c488f2
MD5 195cfa443457528d9a584a285282027d
BLAKE2b-256 3247bd854a688472f43888b298d15dcdc7a840d33083f5a94f4537e402333e92

See more details on using hashes here.

File details

Details for the file active_redis-0.0.2.macosx-10.4-x86_64.exe.

File metadata

File hashes

Hashes for active_redis-0.0.2.macosx-10.4-x86_64.exe
Algorithm Hash digest
SHA256 79780b0604d60cdf53bc0bb51e73973193bc74e5ff779ed8a80d4aa6083f65bf
MD5 7b8c5c0025617b46a5d404507d48aa1f
BLAKE2b-256 0eeef2d1bf5bc92d606085a8894c1ac6a07289a1eb0fba6ea399a2f0e986e889

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page