File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff 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)
185185def 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)
190190def 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)
222222def 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)
227227def 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
234234The ORM integration is optional - SQLAlchemy and Django are not required dependencies.
You can’t perform that action at this time.
0 commit comments