mirror of
https://github.com/donnemartin/system-design-primer.git
synced 2025-12-17 10:28:57 +03:00
Merge 1fc3a36ab2 into 40d5d2edcc
This commit is contained in:
@@ -1218,9 +1218,11 @@ The application is responsible for reading and writing from storage. The cache
|
||||
```python
|
||||
def get_user(self, user_id):
|
||||
user = cache.get("user.{0}", user_id)
|
||||
if user is None:
|
||||
if user:
|
||||
return user
|
||||
|
||||
user = db.query("SELECT * FROM users WHERE user_id = {0}", user_id)
|
||||
if user is not None:
|
||||
if user:
|
||||
key = "user.{0}".format(user_id)
|
||||
cache.set(key, json.dumps(user))
|
||||
return user
|
||||
|
||||
Reference in New Issue
Block a user