mirror of
https://github.com/Quiq/docker-registry-ui.git
synced 2025-07-20 17:09:12 +00:00
Cache invalidate mechanisms
This commit is contained in:
parent
ae0e8f570d
commit
b2f03f5bd3
6
main.go
6
main.go
@ -170,6 +170,7 @@ func main() {
|
|||||||
e.GET(a.config.BasePath+"/", a.dispatchRequest)
|
e.GET(a.config.BasePath+"/", a.dispatchRequest)
|
||||||
e.GET(a.config.BasePath+"/*", a.dispatchRequest)
|
e.GET(a.config.BasePath+"/*", a.dispatchRequest)
|
||||||
e.GET(a.config.BasePath+"/events", a.viewLog)
|
e.GET(a.config.BasePath+"/events", a.viewLog)
|
||||||
|
e.GET(a.config.BasePath+"/invalidate_cache", a.invalidateCache)
|
||||||
|
|
||||||
// Protected event listener.
|
// Protected event listener.
|
||||||
p := e.Group(a.config.BasePath + "/api")
|
p := e.Group(a.config.BasePath + "/api")
|
||||||
@ -208,6 +209,11 @@ func (a *apiClient) dispatchRequest(c echo.Context) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *apiClient) invalidateCache(c echo.Context) error {
|
||||||
|
a.client.InvalidateCache()
|
||||||
|
return c.Redirect(http.StatusSeeOther, a.config.BasePath+"/")
|
||||||
|
}
|
||||||
|
|
||||||
func (a *apiClient) listRepo(c echo.Context, repoPath string) error {
|
func (a *apiClient) listRepo(c echo.Context, repoPath string) error {
|
||||||
tags := a.client.Tags(repoPath)
|
tags := a.client.Tags(repoPath)
|
||||||
repos := a.client.RepositoriesList(true)
|
repos := a.client.RepositoriesList(true)
|
||||||
|
@ -152,6 +152,11 @@ func (c *Client) callRegistry(uri, scope, manifestFormat string) (string, gorequ
|
|||||||
return data, resp
|
return data, resp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) InvalidateCache() {
|
||||||
|
c.logger.Info("Cache invalidated")
|
||||||
|
c.repos = []string{}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Client) RepositoriesList(useCache bool) []string {
|
func (c *Client) RepositoriesList(useCache bool) []string {
|
||||||
// Return from cache if available.
|
// Return from cache if available.
|
||||||
if len(c.repos) > 0 && useCache {
|
if len(c.repos) > 0 && useCache {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div style="float: right">
|
<div style="float: right">
|
||||||
<h4><a href="{{ basePath }}/events">Event Log</a></h4>
|
<h4><a href="{{ basePath }}/events">Event Log</a></h4>
|
||||||
|
<h4><a href="{{ basePath }}/invalidate_cache">Invalidate cache</a></h4>
|
||||||
</div>
|
</div>
|
||||||
<div style="clear: both"></div>
|
<div style="clear: both"></div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user