Comments (3)
Walrus extends the redis-py client so all the redis methods are available: https://redis-py.readthedocs.io/en/stable/commands.html#redis.commands.core.CoreCommands.expire
from walrus.
@coleifer
I am trying to expire the key as below, but getting the object has no attribute expire error
from walrus import Model, TextField, DateTimeField, Database
db = Database(host="host", port="port")
class Hello(Model):
__database__ = db
name = TextField(primary_key=True)
...
user_drop = Hello.get(Hello.name == "some_name")
user_drop.expire(10)
Am I missing something or is there another way of handling it?
from walrus.
Models are not a good fit for simple expiry since they may contain a number of values stored in indexes, but if you are not using any indexes you can:
user_drop = Hello.get(...)
user_hash = user_drop.to_hash() # Get corresponding hash.
user_hash.expire(10) # Will expire the underlying hash, but not the data in the indexes.
To see what is necessary to remove from indexes, see the Model.delete()
code in the models.py
file. In short, models are composite data-structures are will not play well with simple expiration logic.
from walrus.
Related Issues (20)
- "lock.event:" pollution HOT 4
- [feature]Any plan for supporting model relationship mapping? HOT 1
- Consumer group pending exception HOT 1
- VSCode type checking can't identify RedisPy's Redis as parent HOT 2
- Database() is falsy when database is empty HOT 2
- Empty queries in graph HOT 1
- A problem with query in graph.py HOT 1
- Lock event keys never expire HOT 1
- There is a problem. HOT 3
- Walrus Support for Redis Python Client 4.x+ HOT 2
- Missing argument in method calling
- Support from_url database connection HOT 2
- Extending Containers with custom behavior HOT 1
- Not compatible with Redis Python Client 5.0.0 HOT 5
- examples in docs use Python 2 syntax
- Handling json HOT 3
- regex error HOT 1
- regex syntax warning
- about re match HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from walrus.