From 0d314840040a7dc458a8faac2c6aa3d1d4345581 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Mon, 27 Mar 2017 14:47:10 -0700 Subject: Add long polling diagrams [ci skip] --- doc/development/img/cache-hit.svg | 21 +++++++++++++++++++++ doc/development/img/cache-miss.svg | 24 ++++++++++++++++++++++++ doc/development/polling.md | 3 +++ 3 files changed, 48 insertions(+) create mode 100644 doc/development/img/cache-hit.svg create mode 100644 doc/development/img/cache-miss.svg diff --git a/doc/development/img/cache-hit.svg b/doc/development/img/cache-hit.svg new file mode 100644 index 00000000000..1c37693df2d --- /dev/null +++ b/doc/development/img/cache-hit.svg @@ -0,0 +1,21 @@ + + +# Generated by mscgen_js - https://sverweij.github.io/mscgen_js +msc { + # options + hscale="1.5"; + + # entities + c [label="Client", textbgcolor="lime"], + rails [label="Rails", textbgcolor="cyan"], + etag [label="EtagCaching", textbgcolor="orange"], + redis [label="Redis", textbgcolor="white"]; + + # arcs + c => rails [label="GET /projects/5/pipelines"]; + rails => etag [label="GET /projects/5/pipelines"]; + etag => redis [label="read(key = 'GET <Etag>')"]; + redis => etag [label="cache hit", linecolor="green", textcolor="green"]; + |||; + etag => c [label="304 Not Modified", linecolor="blue", textcolor="blue"]; +}ClientRailsEtagCachingRedisGET /projects/5/pipelinesGET /projects/5/pipelinesread(key = 'GET <Etag>')cache hit304 Not Modified \ No newline at end of file diff --git a/doc/development/img/cache-miss.svg b/doc/development/img/cache-miss.svg new file mode 100644 index 00000000000..8429e6a1918 --- /dev/null +++ b/doc/development/img/cache-miss.svg @@ -0,0 +1,24 @@ + + +# Generated by mscgen_js - https://sverweij.github.io/mscgen_js +msc { + # options + hscale="1.5"; + + # entities + c [label="Client", textbgcolor="lime"], + rails [label="Rails", textbgcolor="cyan"], + etag [label="EtagCaching", textbgcolor="orange"], + redis [label="Redis", textbgcolor="white"]; + + # arcs + c => rails [label="GET /projects/5/pipelines"]; + rails => etag [label="GET /projects/5/pipelines"]; + etag => redis [label="read(key = 'GET <Etag>')"]; + redis => etag [label="cache miss", linecolor="red", textcolor="red"]; + |||; + etag => redis [label="write('<New Etag>')"]; + etag => rails [label="GET /projects/5/pipelines"]; + rails => c [label="JSON response w/ ETag", linecolor="blue", textcolor="blue"]; +} +ClientRailsEtagCachingRedisGET /projects/5/pipelinesGET /projects/5/pipelinesread(key = 'GET <Etag>')cache misswrite('<New Etag>')GET /projects/5/pipelinesJSON response w/ ETag \ No newline at end of file diff --git a/doc/development/polling.md b/doc/development/polling.md index a7f2962acf0..e5a717f712b 100644 --- a/doc/development/polling.md +++ b/doc/development/polling.md @@ -22,6 +22,9 @@ Instead you should use polling mechanism with ETag caching in Redis. ## How it works +![Cache miss](img/cache-miss.svg) +![Cache hit](img/cache-hit.svg) + 1. Whenever a resource changes we generate a random value and store it in Redis. 1. When a client makes a request we set the `ETag` response header to the value -- cgit v1.2.1