Skip to content

Commit 45416b5

Browse files
committed
doc: improvements to the README file
Closes #50
1 parent 8677785 commit 45416b5

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Rultor.com](https://www.rultor.com/b/dartoos-dev/json_cache)](https://www.rultor
2828
- [JsonCacheLocalStorage — LocalStorage](#jsoncachelocalstorage)
2929
- [JsonCacheCrossLocalStorage — CrossLocalStorage](#jsoncachecrosslocalstorage)
3030
- [Demo application](#demo-application)
31+
- [Contribute](#contribute)
3132
- [References](#references)
3233

3334
## Overview
@@ -49,9 +50,9 @@ _[JsonCache](https://pub.dev/documentation/json_cache/latest/json_cache/JsonCach
4950
**Why Json?**
5051

5152
- Because most of the local storage packages available for Flutter applications
52-
use json as the data format.
53+
use Json as the data format.
5354
- There is a one-to-one relationship between Dart's built-in type `Map<String,
54-
dynamic>` and json, which makes encoding/decoding data in json a trivial task.
55+
dynamic>` and Json, which makes encoding/decoding data in Json a trivial task.
5556

5657
## Getting Started
5758

@@ -150,6 +151,7 @@ object. For example:
150151
await jsonCache.remove(userId);
151152
}
152153
```
154+
153155
#### Cache Initialization
154156

155157
[JsonCacheMem.init](https://pub.dev/documentation/json_cache/latest/json_cache/JsonCacheMem/JsonCacheMem.init.html)
@@ -227,13 +229,30 @@ with it.
227229
To run the demo application:
228230

229231
```shell
230-
git clone https://github.com/dartoos-dev/json_cache.git
231-
cd json_cache/example/
232-
flutter run -d chrome
232+
git clone https://github.com/dartoos-dev/json_cache.git
233+
cd json_cache/example/
234+
flutter run -d chrome
233235
```
234236

235237
This should launch the demo application on Chrome in debug mode.
236238

239+
## Contribute
240+
241+
Contributors are welcome!
242+
243+
1. Open an issue regarding an improvement, a bug you noticed, or ask to be
244+
assigned to an existing one.
245+
2. If the issue is confirmed, fork the repository, do the changes on a separate
246+
branch and make a Pull Request.
247+
3. After review and acceptance, the PR is merged and closed.
248+
249+
Make sure the commands below **passes** before making a Pull Request.
250+
251+
```shell
252+
flutter analyze
253+
flutter test
254+
```
255+
237256
## References
238257

239258
- [Caching for objects](https://www.pragmaticobjects.com/chapters/012_caching_for_objects.html)

lib/src/json_cache_mem.dart

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ typedef OnInitError = FutureOr<Null> Function(Object, StackTrace);
1212
///
1313
/// It is a kind of level 1 cache.
1414
///
15-
/// TODO: limit the maximum number of cache entries via "size" parameter in
16-
/// constructors.
17-
///
1815
/// It encapsulates a slower cache and keeps its own data in-memory.
1916
class JsonCacheMem implements JsonCache {
2017
/// In-memory level1 cache with an optional level2 instance.
@@ -108,14 +105,14 @@ class JsonCacheMem implements JsonCache {
108105
/// cache.
109106
@override
110107
Future<void> refresh(String key, Map<String, dynamic> data) async {
111-
/// ATTENTION: It is safer to copy the content of [data] before calling an
112-
/// asynchronous method that will copy it to avoid data races. For example,
113-
/// if the client code clears [data] right after passing it to this method,
114-
/// there's a high chance of having _level2 and this object with different
115-
/// contents.
116-
///
117-
/// In Dart, synchronous code cannot be interrupted, so there is no need to
118-
/// protect it using mutual exclusion.
108+
// ATTENTION: It is safer to copy the content of [data] before calling an
109+
// asynchronous method that will copy it to avoid data races. For example,
110+
// if the client code clears [data] right after passing it to this method,
111+
// there's a high chance of having _level2 and this object with different
112+
// contents.
113+
//
114+
// In Dart, synchronous code cannot be interrupted, so there is no need to
115+
// protect it using mutual exclusion.
119116
final copy = Map<String, dynamic>.of(data);
120117
await _mutex.protectWrite(() async {
121118
await _level2.refresh(key, copy);

0 commit comments

Comments
 (0)