inline GC in expiring cache

This allows us to drop the background goroutine with negligable
difference in performance.
This commit is contained in:
Mike Danese
2019-11-15 17:04:28 -08:00
parent f2469a7a2c
commit d16dde36a3
11 changed files with 41 additions and 115 deletions

View File

@@ -17,7 +17,6 @@ limitations under the License.
package authenticator
import (
"context"
"time"
"github.com/go-openapi/spec"
@@ -193,7 +192,7 @@ func (config Config) New() (authenticator.Request, *spec.SecurityDefinitions, er
tokenAuth := tokenunion.New(tokenAuthenticators...)
// Optionally cache authentication results
if config.TokenSuccessCacheTTL > 0 || config.TokenFailureCacheTTL > 0 {
tokenAuth = tokencache.New(context.TODO(), tokenAuth, true, config.TokenSuccessCacheTTL, config.TokenFailureCacheTTL)
tokenAuth = tokencache.New(tokenAuth, true, config.TokenSuccessCacheTTL, config.TokenFailureCacheTTL)
}
authenticators = append(authenticators, bearertoken.New(tokenAuth), websocket.NewProtocolAuthenticator(tokenAuth))
securityDefinitions["BearerToken"] = &spec.SecurityScheme{
@@ -313,5 +312,5 @@ func newWebhookTokenAuthenticator(webhookConfigFile string, version string, ttl
return nil, err
}
return tokencache.New(context.TODO(), webhookTokenAuthenticator, false, ttl, ttl), nil
return tokencache.New(webhookTokenAuthenticator, false, ttl, ttl), nil
}