Reading an item through the cache
Five participants, each kind in its own shape, and ten numbered messages: calls with filled heads activate their receiver until it replies with a dashed line, asynchronous messages have open heads, and an alt fragment frames the cached and the uncached branch. The description and the data table list every message in order.
Reading an item through the cache
examples/cache-lookup.json{
"schemaVersion": 1,
"type": "sequence",
"title": "Reading an item through the cache",
"source": "Service handbook, request flow",
"width": 800,
"height": 670,
"sequence": {
"participants": [
{
"id": "user",
"label": "Reader",
"kind": "actor"
},
{
"id": "api",
"label": "Item API",
"sublabel": "HTTP :8080"
},
{
"id": "cache",
"label": "Cache",
"sublabel": "in memory",
"kind": "database"
},
{
"id": "db",
"label": "Item store",
"sublabel": "Postgres",
"kind": "database"
},
{
"id": "events",
"label": "Change feed",
"kind": "queue"
}
],
"messages": [
{
"from": "user",
"to": "api",
"label": "GET /items/42"
},
{
"from": "api",
"to": "api",
"label": "check token"
},
{
"from": "api",
"to": "cache",
"label": "get item:42"
},
{
"from": "cache",
"to": "api",
"label": "hit",
"kind": "reply"
},
{
"from": "cache",
"to": "api",
"label": "miss",
"kind": "reply"
},
{
"from": "api",
"to": "db",
"label": "SELECT item 42"
},
{
"from": "db",
"to": "api",
"label": "row",
"kind": "reply"
},
{
"from": "api",
"to": "cache",
"label": "set item:42, 5 min",
"kind": "async"
},
{
"from": "api",
"to": "events",
"label": "item.read",
"kind": "async"
},
{
"from": "api",
"to": "user",
"label": "200 OK",
"kind": "reply"
}
],
"fragments": [
{
"kind": "alt",
"label": "cached",
"from": 3,
"to": 7,
"else": [
{
"from": 4,
"label": "not cached"
}
]
}
],
"numbered": true
}
}Focus
Source: Service handbook, request flow
Show chart data
| No. | From | To | Message | Kind | Fragment |
|---|---|---|---|---|---|
| 1 | Reader | Item API | GET /items/42 | call | |
| 2 | Item API | Item API | check token | call | |
| 3 | Item API | Cache | get item:42 | call | |
| 4 | Cache | Item API | hit | reply | alt [cached] |
| 5 | Cache | Item API | miss | reply | alt [not cached] |
| 6 | Item API | Item store | SELECT item 42 | call | alt [not cached] |
| 7 | Item store | Item API | row | reply | alt [not cached] |
| 8 | Item API | Cache | set item:42, 5 min | asynchronous | alt [not cached] |
| 9 | Item API | Change feed | item.read | asynchronous | |
| 10 | Item API | Reader | 200 OK | reply |