@@ -6,7 +6,7 @@ import { KernelError, Notebook, NotebookActions } from '@jupyterlab/notebook';
66import { Cell } from '@jupyterlab/cells' ;
77import { ISettingRegistry } from '@jupyterlab/settingregistry' ;
88import { ICodeCellModel } from '@jupyterlab/cells' ;
9-
9+ import LRU from 'lru-cache' ;
1010import { checkBrowserNotificationSettings } from './settings' ;
1111
1212interface ICellExecutionMetadata {
@@ -106,9 +106,10 @@ const extension: JupyterFrontEndPlugin<void> = {
106106 const cellExecutionMetadataTable : {
107107 [ cellId : string ] : ICellExecutionMetadata ;
108108 } = { } ;
109- const recentNotebookExecutionTimes : {
110- [ notebookId : string ] : Date ;
111- } = { } ;
109+ const recentNotebookExecutionTimes : LRU < string , Date > = new LRU ( {
110+ max : 500 ,
111+ maxAge : 1000 * 60 * 60 * 10 // 10 hours
112+ } ) ;
112113
113114 if ( settingRegistry ) {
114115 const setting = await settingRegistry . load ( extension . id ) ;
@@ -144,13 +145,13 @@ const extension: JupyterFrontEndPlugin<void> = {
144145 const notebookId = notebook . id ;
145146 const scheduledTime = cellExecutionMetadataTable [ cellId ] . scheduledTime ;
146147 const recentExecutedCellTime =
147- recentNotebookExecutionTimes [ notebookId ] || scheduledTime ;
148+ recentNotebookExecutionTimes . get ( notebookId ) || scheduledTime ;
148149 cellExecutionMetadataTable [ cellId ] . startTime =
149150 scheduledTime >= recentExecutedCellTime
150151 ? scheduledTime
151152 : recentExecutedCellTime ;
152153 cellExecutionMetadataTable [ cellId ] . endTime = cellEndTime ;
153- recentNotebookExecutionTimes [ notebookId ] = cellEndTime ;
154+ recentNotebookExecutionTimes . set ( notebookId , cellEndTime ) ;
154155
155156 triggerNotification (
156157 cell ,
0 commit comments