Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cache time for / index request #631

Merged
merged 2 commits into from
Sep 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

* Add `cache_time.index` as config option. [#631](https://github.com/elastic/package-registry/pull/631)

### Deprecated

### Known Issue
Expand Down
1 change: 1 addition & 0 deletions config.docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public_dir: ./public
package_paths:
- /packages/package-registry

cache_time.index: 10s
cache_time.search: 10m
cache_time.categories: 10m
cache_time.catch_all: 10m
1 change: 1 addition & 0 deletions config.reference.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package_paths:
- ./packages

cache_time.index: 10s
cache_time.search: 10m
cache_time.categories: 10m
cache_time.catch_all: 10m
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var (

defaultConfig = Config{
PublicDir: "./public", // left for legacy purposes
CacheTimeIndex: 10 * time.Second,
CacheTimeSearch: 10 * time.Minute,
CacheTimeCategories: 10 * time.Minute,
CacheTimeCatchAll: 10 * time.Minute,
Expand All @@ -54,6 +55,7 @@ func init() {
type Config struct {
PublicDir string `config:"public_dir"` // left for legacy purposes
PackagePaths []string `config:"package_paths"`
CacheTimeIndex time.Duration `config:"cache_time.index"`
CacheTimeSearch time.Duration `config:"cache_time.search"`
CacheTimeCategories time.Duration `config:"cache_time.categories"`
CacheTimeCatchAll time.Duration `config:"cache_time.catch_all"`
Expand Down Expand Up @@ -164,7 +166,7 @@ func getRouter(config *Config, packagesBasePaths []string) (*mux.Router, error)
if err != nil {
return nil, err
}
indexHandlerFunc, err := indexHandler(config.CacheTimeCatchAll)
indexHandlerFunc, err := indexHandler(config.CacheTimeIndex)
if err != nil {
return nil, err
}
Expand Down