Skip to content

Commit

Permalink
Align memstorage interface
Browse files Browse the repository at this point in the history
  • Loading branch information
dnys1 committed Mar 7, 2024
1 parent 392a00c commit 73b11d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/celest_core/lib/src/storage/memory_storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import 'package:celest_core/src/storage/storage.dart';
/// An in-memory implementation of [Storage] and [SecureStorage].
final class MemoryStorage implements Storage, SecureStorage {
MemoryStorage({
required this.scope,
});
String? scope,
}) : scope = scope ?? _defaultScope;

final _storage = <String, String>{};
final String scope;

static const _defaultScope = 'dev.celest.cli';

@override
void clear() => _storage.removeWhere((key, _) => key.startsWith('$scope/'));

Expand Down
2 changes: 2 additions & 0 deletions packages/celest_core/lib/src/storage/storage.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:celest_core/src/storage/local/local_storage.dart';
import 'package:celest_core/src/storage/memory_storage.dart';
import 'package:celest_core/src/storage/secure/secure_storage.dart';

abstract interface class Storage {
factory Storage.memory({String? scope}) = MemoryStorage;
factory Storage.local({String? scope}) = LocalStorage;
factory Storage.secure({String? scope}) = SecureStorage;

Expand Down

0 comments on commit 73b11d7

Please sign in to comment.