Use cache in fetching post data
Getty Ritter
7 years ago
| 70 | 70 | Web.ok user "New Post" contents |
| 71 | 71 | |
| 72 | 72 | ("GET", [y, m, s]) -> do |
| 73 | post <- DB.runDB (DB.postByDateAndSlug y m s) c | |
| 74 | contents <- Template.post user post | |
| 75 |
|
|
| 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 | |
| 76 | 84 | |
| 77 | 85 | ("POST", [y, m, s]) -> |
| 78 | 86 | case user of |