83
84
constructor(
85
>
private readonly _storageDataKey: string,
history.ts
86
>
@IConfigurationService private readonly _configurationService: IConfigurationService,
87
>
@IStorageService private readonly _storageService: IStorageService,
88
>
) {
89
>
super();
90
>
91
>
// Init cache
92
>
this._entries = new LRUCache<string, T>(this._getHistoryLimit());
93
>
94
>
// Listen for config changes to set history limit
95
>
this._register(this._configurationService.onDidChangeConfiguration(e => {
96
if (e.affectsConfiguration(TerminalHistorySettingId.ShellIntegrationCommandHistory)) {
97
this._entries.limit = this._getHistoryLimit();
98
}
100
>
101
>
// Listen to cache changes from other windows
102
>
this._register(this._storageService.onDidChangeValue(StorageScope.APPLICATION, this._getTimestampStorageKey(), this._store)(() => {
103
>
if (!this._isStale) {
104
>
this._isStale = this._storageService.getNumber(this._getTimestampStorageKey(), StorageScope.APPLICATION, 0) !== this._timestamp;
105
>
}
106
>
}));
107
>
}
108
109
add(key: string, value: T) {
111
>
this._entries.set(key, value);
112
>
this._saveState();
113
>
}
114
115
remove(key: string) {