Conversation
|
@kvigen @samfishman this morning @Sayan- and I added cache hit/miss logging to this. I think we can use https://github.com/die-net/lrucache as the cache implementation, since this will give us byte-size limiting and also some nice-to-have LRU eviction logic. I think the next steps from here:
|
There was a problem hiding this comment.
looks good!
have we vetted https://github.com/die-net/lrucache carefully? it doesn't have a ton of github stars and lru cache performance can be tricky. an alternative might be: https://github.com/karlseguin/ccache, but i don't know how difficult that will be to integrate with httpcache
also, thinking more about app-service + HM, i'm realizing that we have a challenge that when someone makes a change in HM they expect to see the change show up immediately. Not sure if there this is going to cause problems with the endpoints we're thinking about, or whether we should think about that case too
| @@ -1,5 +1,3 @@ | |||
| // Code generated by go-swagger; DO NOT EDIT. | |||
There was a problem hiding this comment.
i assume this is from a go-swagger update?
| require.NoError(t, err) | ||
| } | ||
| require.Equal(t, controller.getCachedCount, 2, "expected a second request to go through") | ||
|
|
| type cacheHitCounter struct { | ||
| httpcache.Cache | ||
| hits int64 | ||
| misses int64 |
There was a problem hiding this comment.
probably not worth it yet, but i could see us wanting to know this on a per-endpoint basis
| results, again requesting new pages as needed. | ||
|
|
||
| ### Caching | ||
| * Wag can add `max-age` cache-control headers on respones if you use the `x-caching` |
There was a problem hiding this comment.
nit: mention that max-age is in seconds
| operationId: getBookByIDCached | ||
| description: Retrieve a book | ||
| x-caching: | ||
| max-age: 3 |
There was a problem hiding this comment.
does it make sense to make this 1 so the tests run more quickly, or does that make the tests unstable?
adds a
x-cachingextension that you can configure endpoints with. Only supports addingmax-ageheaders on responsesadds caching support go clients via https://github.com/gregjones/httpcache
not done:
gregjones/httpcachehas an in memory cache we could use, but it doesn't limit the size of the cache in any way.wagshould probably wrap this to have a limitwagshould report a counter of cache hits/missescaching in the js client 😨