gdritter repos new-inf-blog / cbfcd0a
Use cache in fetching post data Getty Ritter 6 years ago
1 changed file(s) with 11 addition(s) and 3 deletion(s). Collapse all Expand all
7070 Web.ok user "New Post" contents
7171
7272 ("GET", [y, m, s]) -> do
73 post <- DB.runDB (DB.postByDateAndSlug y m s) c
74 contents <- Template.post user post
75 Web.ok user (T.fromStrict (postTitle post)) contents
73 (post, cached) <- flip DB.runDB c $ do
74 ps <- DB.postByDateAndSlug y m s
75 ch <- DB.cachedMarkup (postId ps)
76 pure (ps, ch)
77 case cached of
78 Just cache -> do
79 Web.ok user (T.fromStrict (postTitle post)) cache
80 Nothing -> do
81 contents <- Template.post user post
82 DB.runDB (DB.storeCachedMarkup (postId post) contents) c
83 Web.ok user (T.fromStrict (postTitle post)) contents
7684
7785 ("POST", [y, m, s]) ->
7886 case user of