File tree Expand file tree Collapse file tree 11 files changed +26
-17
lines changed Expand file tree Collapse file tree 11 files changed +26
-17
lines changed Original file line number Diff line number Diff line change @@ -9,17 +9,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
10
10
### Added
11
11
12
- - Method " keys" for listing all cache keys —
12
+ - Method ` keys ` for listing all cache keys —
13
13
[ 152] ( https://github.com/dartoos-dev/json_cache/issues/152 )
14
14
15
15
### Changed
16
16
17
- - Mehtod "keys" returns an immutable copy of the underlying cache keys —
18
- [ 165 ] ( https://github.com/dartoos-dev/json_cache/issues/152 )
17
+ - Make ` JsonCache ` a Dart interface and mark implementations as ` final ` — ** BREAKING CHANGE ** —
18
+ [ 168 ] ( https://github.com/dartoos-dev/json_cache/issues/168 ) .
19
19
20
20
- Update linting rules —
21
21
[ 162] ( https://github.com/dartoos-dev/json_cache/issues/154 ) .
22
22
23
+ ### Fixed
24
+
25
+ - Mehtod ` keys ` returns an immutable copy of the underlying cache keys —
26
+ [ 165] ( https://github.com/dartoos-dev/json_cache/issues/152 )
27
+
23
28
## [ 3.0.2] - 2024-08-19
24
29
25
30
### Changed
Original file line number Diff line number Diff line change @@ -2,12 +2,12 @@ import 'dart:collection';
2
2
3
3
/// Represents cached data in json format.
4
4
///
5
- ///> Cache is a hardware or software component that stores data so that future
6
- ///> requests for that data can be served faster; the data stored in a cache
7
- ///> might be the result of an earlier computation or a copy of data stored
8
- ///> elsewhere.
5
+ ///> " Cache is a hardware or software component that stores data so that future
6
+ ///> requests for that data can be served faster; the data stored in a cache
7
+ ///> might be the result of an earlier computation or a copy of data stored
8
+ ///> elsewhere."
9
9
///> — [cache Wikipedia] (https://en.wikipedia.org/wiki/Cache_(computing))
10
- abstract class JsonCache {
10
+ abstract interface class JsonCache {
11
11
/// Frees up storage space — deletes all keys and values.
12
12
Future <void > clear ();
13
13
Original file line number Diff line number Diff line change 1
1
/// An exception to indicate cache operation failures.
2
- class JsonCacheException <T extends Object > implements Exception {
2
+ final class JsonCacheException <T extends Object > implements Exception {
3
3
/// Sets [extra] as the aditional information and [exception] as the original
4
4
/// exception.
5
5
const JsonCacheException ({required this .extra, this .exception});
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import 'package:json_cache/json_cache.dart';
7
7
/// It is intended for unit testing and prototyping.
8
8
///
9
9
/// **Warning**: do not use it in production code. It is not thread-safe.
10
- class JsonCacheFake implements JsonCache {
10
+ final class JsonCacheFake implements JsonCache {
11
11
/// Shares a static memory with other instances.
12
12
JsonCacheFake () : this .mem (_shrMem);
13
13
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import 'package:json_cache/json_cache.dart';
8
8
///
9
9
/// See also:
10
10
/// - [flutter_secure_storage] (https://pub.dev/packages/flutter_secure_storage).
11
- class JsonCacheFlutterSecureStorage implements JsonCache {
11
+ final class JsonCacheFlutterSecureStorage implements JsonCache {
12
12
/// Sets the [FlutterSecureStorage] instance.
13
13
const JsonCacheFlutterSecureStorage (this ._storage);
14
14
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import 'package:json_cache/json_cache.dart';
7
7
/// Implementation on top of the Hive package.
8
8
///
9
9
/// See: [hive] (https://pub.dev/packages/hive)
10
- class JsonCacheHive implements JsonCache {
10
+ final class JsonCacheHive implements JsonCache {
11
11
/// Sets the Hive [Box] instance.
12
12
const JsonCacheHive (this ._box);
13
13
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import 'package:json_cache/json_cache.dart';
16
16
/// > - Hollow blocks are used because they are lighter
17
17
/// > - a hollow log
18
18
/// > — [Cambridge Dictionary] (https://dictionary.cambridge.org/dictionary/english/hollow)
19
- class JsonCacheHollow implements JsonCache {
19
+ final class JsonCacheHollow implements JsonCache {
20
20
/// This const constructor ensures that there will be only one
21
21
/// [JsonCacheHollow] instance throughout the program.
22
22
const JsonCacheHollow ();
Original file line number Diff line number Diff line change @@ -9,12 +9,16 @@ import 'package:mutex/mutex.dart';
9
9
/// [JsonCacheMem.init] initialization error callback.
10
10
typedef OnInitError = FutureOr <Null > Function (Object , StackTrace );
11
11
12
+ /// {@template json_cache_mem}
13
+ ///
12
14
/// Thread-safe in-memory [JsonCache] decorator.
13
15
///
14
16
/// It is a kind of _level 1_ cache.
15
17
///
16
18
/// It encapsulates a slower cache and keeps its own data in-memory.
17
- class JsonCacheMem implements JsonCache {
19
+ ///
20
+ /// {@endtemplate}
21
+ final class JsonCacheMem implements JsonCache {
18
22
/// In-memory _level 1_ cache with an optional _level 2_ instance.
19
23
///
20
24
/// **Note**: if you do not pass an object to the parameter [level2] , the data
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import 'package:safe_local_storage/safe_local_storage.dart';
8
8
/// Implementation on top of the SafeLocalStorage package.
9
9
///
10
10
/// See: [Safe local storage] (https://pub.dev/packages/safe_local_storage)
11
- class JsonCacheSafeLocalStorage implements JsonCache {
11
+ final class JsonCacheSafeLocalStorage implements JsonCache {
12
12
/// Encapsulates a [SafeLocalStorage] instance.
13
13
const JsonCacheSafeLocalStorage (this ._localStorage);
14
14
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import 'package:json_cache/json_cache.dart';
5
5
import 'package:shared_preferences/shared_preferences.dart' ;
6
6
7
7
/// Persistent preferences file cache.
8
- class JsonCacheSharedPreferences implements JsonCache {
8
+ final class JsonCacheSharedPreferences implements JsonCache {
9
9
/// Sets the [SharedPreferences] instance.
10
10
const JsonCacheSharedPreferences (this ._sharedPreferences);
11
11
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import 'package:json_cache/json_cache.dart';
4
4
5
5
/// A [JsonCache] decorator that provides improved information about
6
6
/// cache-related failures by throwing [JsonCacheException] .
7
- class JsonCacheTry implements JsonCache {
7
+ final class JsonCacheTry implements JsonCache {
8
8
/// Sets [wrapped] as the instance to which this object will forward all
9
9
/// method calls.
10
10
///
You can’t perform that action at this time.
0 commit comments