System Overview - Design a key-value store
This system stores and retrieves data as key-value pairs. It must handle many requests quickly and keep data safe and consistent. The system should scale to support many users and large data volumes.
Jump into concepts and practice - no test required
This system stores and retrieves data as key-value pairs. It must handle many requests quickly and keep data safe and consistent. The system should scale to support many users and large data volumes.
User
|
v
Load Balancer
|
v
API Gateway
|
v
+-------------------+ +-------------+
| Key-Value Store |<---->| Cache |
| Service | +-------------+
| (Handles logic) |
+-------------------+
|
v
+-------------+
| Database |
+-------------+store = {}
store.put('a', 1)
store.put('b', 2)
store.put('a', 3)
value = store.get('a')
What is the value of value after these operations?store = {}
def get_value(key):
if key in store:
return store[key]
else:
return None
store.put('x', 10)
print(get_value('x'))
What is the main issue preventing this code from working correctly?