Skip to content

Commit 4ebdc9e

Browse files
authored
doc(README) update content
Closes #167
1 parent b710e3b commit 4ebdc9e

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
[168](https://github.com/dartoos-dev/json_cache/issues/168).
1919

2020
- Update linting rules —
21-
[162](https://github.com/dartoos-dev/json_cache/issues/154).
21+
[162](https://github.com/dartoos-dev/json_cache/issues/162).
22+
23+
- Update README — [167](https://github.com/dartoos-dev/json_cache/issues/167).
2224

2325
### Fixed
2426

2527
- Mehtod `keys` returns an immutable copy of the underlying cache keys —
26-
[165](https://github.com/dartoos-dev/json_cache/issues/152)
28+
[165](https://github.com/dartoos-dev/json_cache/issues/165).
2729

2830
## [3.0.2] - 2024-08-19
2931

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ that can be selected and grouped in various combinations to meet specific cache
7272
requirements.
7373

7474
[JsonCache](https://pub.dev/documentation/json_cache/latest/json_cache/JsonCache-class.html)
75-
is the core interface of this package and represents the concept of cached data.
76-
It is defined as:
75+
is the core Dart interface of this package and represents the concept of cached
76+
data. It is defined as:
7777

7878
```dart
7979
/// Represents cached data in json format.
80-
abstract class JsonCache {
80+
abstract interface class JsonCache {
8181
/// Frees up storage space — deletes all keys and values.
8282
Future<void> clear();
8383
@@ -97,6 +97,11 @@ abstract class JsonCache {
9797
///
9898
/// Returns `true` if there is cached data at [key]; `false` otherwise.
9999
Future<bool> contains(String key);
100+
101+
/// The cache keys.
102+
///
103+
/// Returns an **unmodifiable** list of all cache keys without duplicates.
104+
Future<UnmodifiableListView<String>> keys();
100105
}
101106
```
102107

@@ -281,9 +286,14 @@ is an implementation on top of the
281286
[localstorage](https://pub.dev/packages/localstorage) package.
282287

283288
```dart
289+
import 'package:flutter/material.dart';
290+
import 'package:localstorage/localstorage.dart';
291+
284292
285293
final LocalStorage storage = LocalStorage('my_data');
286-
final JsonCache jsonCache = JsonCacheMem(JsonCacheLocalStorage(storage));
294+
WidgetsFlutterBinding.ensureInitialized();
295+
await initLocalStorage();
296+
final JsonCache jsonCache = JsonCacheMem(JsonCacheLocalStorage(localStorage));
287297
288298
```
289299

lib/src/json_cache_hollow.dart

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,28 @@ import 'dart:collection';
22

33
import 'package:json_cache/json_cache.dart';
44

5-
/// Hollow (empty) [JsonCache] — It is intended to serve as a placeholder for
5+
/// {@template json_cache_hollow}
6+
///
7+
/// Hollow [JsonCache] — It is intended to serve as a placeholder for
68
/// [JsonCache] instances.
79
///
810
/// There will always be at most one [JsonCacheHollow] object in memory during
911
/// program execution. It doesn't matter how many times someone instantiates
1012
/// objects using `const JsonCacheHollow()`.
1113
///
12-
/// > hollow
14+
/// > hollow:
15+
/// >
16+
/// > having a hole or empty space inside:
17+
/// > - a hollow tube
18+
/// > - Hollow blocks are used because they are lighter
19+
/// > - a hollow log
1320
/// >
14-
/// > having a hole or empty space inside:
15-
/// > - a hollow tube
16-
/// > - Hollow blocks are used because they are lighter
17-
/// > - a hollow log
1821
/// > — [Cambridge Dictionary](https://dictionary.cambridge.org/dictionary/english/hollow)
22+
///
23+
/// {@endtemplate}
1924
final class JsonCacheHollow implements JsonCache {
25+
/// {@macro json_cache_hollow}
26+
///
2027
/// This const constructor ensures that there will be only one
2128
/// [JsonCacheHollow] instance throughout the program.
2229
const JsonCacheHollow();

0 commit comments

Comments
 (0)