Skip to content

Commit 574282c

Browse files
committed
imrpove readme for basic usage
1 parent 21e7478 commit 574282c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ memory_cache = EntityCache()
9191
#### With Entity Tracking
9292

9393
```python
94-
# Cache function results and track entity reference for invalidation
95-
@cache('user') # "user" - is entity used later *only for invalidation*
94+
# Cache function results and track entity reference *only* for invalidation
95+
@cache.track('user') # Track 'user' entities for targeted invalidation
9696
def get_user(user_id):
97-
# Your database/interservice query here
98-
# 'id' is default id_key for tracking so-called 'user' entity
97+
# database/interservice query...
98+
# 'id' is default id_key for tracking the 'user' entity
9999
return {"id": user_id, "name": f"User {user_id}"}
100100

101101
# Get user (will be cached)
@@ -111,7 +111,7 @@ def update_users(user_ids, data):
111111
# Or manually invalidate
112112
def delete_user(user_id):
113113
# Delete from database...
114-
# Then invalidate all caches containing this user
114+
# Then invalidate all cached functions that was containing this user id in return
115115
cache.invalidate_entity("user", user_id)
116116
```
117117

0 commit comments

Comments
 (0)