updateTimelineCache will reset and update the cache if it is stale or the boolean passed in is true.
(tl *localTimeline, reset bool)
| 161 | // updateTimelineCache will reset and update the cache if it is stale or |
| 162 | // the boolean passed in is true. |
| 163 | func updateTimelineCache(tl *localTimeline, reset bool) { |
| 164 | if reset { |
| 165 | tl.m.Reset() |
| 166 | } |
| 167 | |
| 168 | // Fetch posts if the cache is empty, has been reset or enough time has |
| 169 | // passed since last cache. |
| 170 | if tl.posts == nil || reset || tl.m.Invalidate() { |
| 171 | log.Info("[READ] Updating post cache") |
| 172 | |
| 173 | postsInterfaces, err := tl.m.Get() |
| 174 | if err != nil { |
| 175 | log.Error("[READ] Unable to cache posts: %v", err) |
| 176 | } else { |
| 177 | castPosts := postsInterfaces.([]PublicPost) |
| 178 | tl.posts = &castPosts |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | } |
| 183 | |
| 184 | func showLocalTimeline(app *App, w http.ResponseWriter, r *http.Request, page int, author, tag string) error { |
| 185 | updateTimelineCache(app.timeline, false) |
no outgoing calls
no test coverage detected