-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add APIs to invalidate frame and executable caches
The two new endpoints will clear each respective cache.
- Loading branch information
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { RouteRegisterParameters } from '.'; | ||
import { getRoutePaths } from '../../common'; | ||
import { handleRouteHandlerError } from '../utils/handle_route_error_handler'; | ||
import { clearExecutableCache, clearStackFrameCache } from './stacktrace'; | ||
|
||
export function registerCacheExecutablesRoute({ router, logger }: RouteRegisterParameters) { | ||
const paths = getRoutePaths(); | ||
router.delete( | ||
{ | ||
path: paths.CacheExecutables, | ||
validate: {}, | ||
}, | ||
async (context, request, response) => { | ||
try { | ||
logger.info(`clearing executable cache`); | ||
const numDeleted = clearExecutableCache(); | ||
logger.info(`removed ${numDeleted} executables from cache`); | ||
|
||
return response.ok({}); | ||
} catch (error) { | ||
return handleRouteHandlerError({ error, logger, response }); | ||
} | ||
} | ||
); | ||
} | ||
|
||
export function registerCacheStackFramesRoute({ router, logger }: RouteRegisterParameters) { | ||
const paths = getRoutePaths(); | ||
router.delete( | ||
{ | ||
path: paths.CacheStackFrames, | ||
validate: {}, | ||
}, | ||
async (context, request, response) => { | ||
try { | ||
logger.info(`clearing stackframe cache`); | ||
const numDeleted = clearStackFrameCache(); | ||
logger.info(`removed ${numDeleted} stackframes from cache`); | ||
|
||
return response.ok({}); | ||
} catch (error) { | ||
return handleRouteHandlerError({ error, logger, response }); | ||
} | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters