redis / redis-om-python

Object mapping, and more, for Redis and Python
MIT License
1.12k stars 112 forks source link

Add expire method inside JsonModel #238

Closed inari6735 closed 2 years ago

simonprickett commented 2 years ago

Is this necessary? expire is in RedisModel that both HashModel and JsonModel extend, so this works already with the current release of Redis OM Python:

# app.py
from redis_om import JsonModel

class TestEntity(JsonModel):
    field_one: str
    field_two: str

some_entity = TestEntity(
    field_one = "Hello",
    field_two = "World"
)

some_entity.save()
some_entity.expire(30)

print(TestEntity.db().ttl(some_entity.key()))
$ python app.py

30
inari6735 commented 2 years ago

Ahh i just worked with the old version of this repo in my project and there was not .expire() method. I missed it. It is not necessary.