提交 6c71798d 编写于 作者: B Benjamin Pasero

storage - 💄

上级 b431db5e
...@@ -55,7 +55,7 @@ export class Storage extends Disposable { ...@@ -55,7 +55,7 @@ export class Storage extends Disposable {
this.storage = new SQLiteStorageImpl(options); this.storage = new SQLiteStorageImpl(options);
this.pendingScheduler = new RunOnceScheduler(() => this.flushPending(), Storage.FLUSH_DELAY); this.pendingScheduler = this._register(new RunOnceScheduler(() => this.flushPending(), Storage.FLUSH_DELAY));
} }
get size(): number { get size(): number {
...@@ -74,7 +74,7 @@ export class Storage extends Disposable { ...@@ -74,7 +74,7 @@ export class Storage extends Disposable {
}); });
} }
get(key: string, fallbackValue?: any): string { get(key: string, fallbackValue?: string): string {
const value = this.cache.get(key); const value = this.cache.get(key);
if (isUndefinedOrNull(value)) { if (isUndefinedOrNull(value)) {
......
...@@ -33,6 +33,7 @@ export class StorageService extends Disposable implements IStorageService { ...@@ -33,6 +33,7 @@ export class StorageService extends Disposable implements IStorageService {
private _onStorageError: Emitter<string | Error> = this._register(new Emitter<string | Error>()); private _onStorageError: Emitter<string | Error> = this._register(new Emitter<string | Error>());
get onStorageError(): Event<string | Error> { get onStorageError(): Event<string | Error> {
if (Array.isArray(this.bufferedStorageErrors)) { if (Array.isArray(this.bufferedStorageErrors)) {
// todo@ben cleanup after a while
if (this.bufferedStorageErrors.length > 0) { if (this.bufferedStorageErrors.length > 0) {
const bufferedStorageErrors = this.bufferedStorageErrors; const bufferedStorageErrors = this.bufferedStorageErrors;
setTimeout(() => { setTimeout(() => {
...@@ -109,7 +110,7 @@ export class StorageService extends Disposable implements IStorageService { ...@@ -109,7 +110,7 @@ export class StorageService extends Disposable implements IStorageService {
]).then(() => void 0); ]).then(() => void 0);
} }
get(key: string, scope: StorageScope, fallbackValue?: any): string { get(key: string, scope: StorageScope, fallbackValue?: string): string {
return this.getStorage(scope).get(key, fallbackValue); return this.getStorage(scope).get(key, fallbackValue);
} }
...@@ -279,7 +280,7 @@ export class DelegatingStorageService extends Disposable implements IStorageServ ...@@ -279,7 +280,7 @@ export class DelegatingStorageService extends Disposable implements IStorageServ
return this.storageService as StorageService; return this.storageService as StorageService;
} }
get(key: string, scope: StorageScope, fallbackValue?: any): string { get(key: string, scope: StorageScope, fallbackValue?: string): string {
if (scope === StorageScope.WORKSPACE) { if (scope === StorageScope.WORKSPACE) {
return this.storageService.get(key, scope, fallbackValue); return this.storageService.get(key, scope, fallbackValue);
} }
......
...@@ -46,10 +46,10 @@ suite('StorageService', () => { ...@@ -46,10 +46,10 @@ suite('StorageService', () => {
strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.get', scope, 'foobar'), 'foobar'); strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.get', scope, 'foobar'), 'foobar');
strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.get', scope, ''), ''); strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.get', scope, ''), '');
strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.getInteger', scope, 5), 5); strictEqual(storage.getInteger('Monaco.IDE.Core.Storage.Test.getInteger', scope, 5), 5);
strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.getInteger', scope, 0), 0); strictEqual(storage.getInteger('Monaco.IDE.Core.Storage.Test.getInteger', scope, 0), 0);
strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.getBoolean', scope, true), true); strictEqual(storage.getBoolean('Monaco.IDE.Core.Storage.Test.getBoolean', scope, true), true);
strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.getBoolean', scope, false), false); strictEqual(storage.getBoolean('Monaco.IDE.Core.Storage.Test.getBoolean', scope, false), false);
storage.store('Monaco.IDE.Core.Storage.Test.get', 'foobar', scope); storage.store('Monaco.IDE.Core.Storage.Test.get', 'foobar', scope);
strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.get', scope), 'foobar'); strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.get', scope), 'foobar');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册