redis对象哈希映射库
oredis的Python项目详细描述
oredis是一个用于在redis(一个持久的键值数据库)中存储对象的库。它包含一个可扩展的验证列表,并且具有非常好的性能。
如何使用
from oredis.models import Model from oredis.manager import Manager from oredis.fields import String, PrimaryKey, StringPK, Integer, DateTime
- class NoteManager(Manager):
- pass
- class NoteModel(Model):
id = PrimaryKey() title = String() pk_hash = StringPK() body = String(required = True)
objects = NoteManager(connection = redis.Redis())
- In [19]: note1 = NoteModel(title = “Hello world!”,
….: body=”I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I’ve noticed that some of our sessions have gotten bogged down in minor details, and I don’t feel I’ve been very organized. (But the answers to this post have helped a lot.)”)在[20]:注1 输出[20]:<;notemodel:942>;
在[21]:注1.标题 “你好,世界!'
在[22]:注1.标题
安装
要使用Oredis,请使用PIP或简易安装:
pip安装oredis
或
轻松安装oredis
贡献
forkhttps://github.com/lispython/oredis/,创建commit和pull请求。
学分
感谢Alexander Solovyov从OREM库中获取的一些概念。