Skip to content

Commit f8119ce

Browse files
committed
orm clarifications for list
1 parent 6e3d93d commit f8119ce

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,15 @@ class User(Base):
183183
# Pass the model class directly - no need to specify entity name or id_key
184184
@cache.tracks(User)
185185
def get_user(user_id):
186-
return session.query(User).get(user_id) # it can return list too
186+
return session.query(User).get(user_id) # you can return list too
187187

188188
# Automatically invalidates cache based on primary key
189189
@cache.invalidates(User)
190190
def update_user(user_id, name):
191191
user = session.query(User).get(user_id)
192192
user.name = name
193193
session.commit()
194-
return user
194+
return user # if list is provided, it invalidates all items
195195

196196
# For manually resetting entity pass table name
197197
# for composite key pass tuple
@@ -220,15 +220,15 @@ class Article(models.Model):
220220
# Pass the model class directly - no need to specify entity name or id_key
221221
@cache.tracks(Article)
222222
def get_article(article_id):
223-
return Article.objects.get(id=article_id) # it can return list too
223+
return Article.objects.get(id=article_id) # you can return list too
224224

225225
# Automatically invalidates cache based on primary key
226226
@cache.invalidates(Article)
227227
def update_article(article_id, title):
228228
article = Article.objects.get(id=article_id)
229229
article.title = title
230230
article.save()
231-
return article
231+
return article # if list is provided, it invalidates all items
232232
```
233233

234234
The ORM integration is optional - SQLAlchemy and Django are not required dependencies.

0 commit comments

Comments
 (0)