mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
Clean expired cache entries periodically
Regularly clean up of cache entries that have expired for a more efficient use of memory. Introduce two new parameters to tune clean up frequency and threshold for forced FIFO eviction. Fixes #5320 Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
This commit is contained in:
committed by
Ashutosh Narkar
parent
ea1ecdfef1
commit
f063c90275
+3
-3
@@ -184,7 +184,7 @@ func New() *Server {
|
||||
// Init initializes the server. This function MUST be called before starting any loops
|
||||
// from s.Listeners().
|
||||
func (s *Server) Init(ctx context.Context) (*Server, error) {
|
||||
s.initRouters()
|
||||
s.initRouters(ctx)
|
||||
|
||||
txn, err := s.store.NewTransaction(ctx, storage.WriteParams)
|
||||
if err != nil {
|
||||
@@ -755,7 +755,7 @@ func (s *Server) initHandlerCompression(handler http.Handler) (http.Handler, err
|
||||
return compressHandler, nil
|
||||
}
|
||||
|
||||
func (s *Server) initRouters() {
|
||||
func (s *Server) initRouters(ctx context.Context) {
|
||||
mainRouter := s.router
|
||||
if mainRouter == nil {
|
||||
mainRouter = mux.NewRouter()
|
||||
@@ -764,7 +764,7 @@ func (s *Server) initRouters() {
|
||||
diagRouter := mux.NewRouter()
|
||||
|
||||
// authorizer, if configured, needs the iCache to be set up already
|
||||
s.interQueryBuiltinCache = iCache.NewInterQueryCache(s.manager.InterQueryBuiltinCacheConfig())
|
||||
s.interQueryBuiltinCache = iCache.NewInterQueryCacheWithContext(ctx, s.manager.InterQueryBuiltinCacheConfig())
|
||||
s.manager.RegisterCacheTrigger(s.updateCacheConfig)
|
||||
|
||||
// Add authorization handler. This must come BEFORE authentication handler
|
||||
|
||||
Reference in New Issue
Block a user