1.0.0
This commit is contained in:
parent
2fdbfccd7d
commit
5295ea57eb
4 changed files with 29 additions and 4 deletions
2
CHANGELOG.md
Normal file
2
CHANGELOG.md
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# 1.0.0
|
||||||
|
* First version
|
22
README.md
22
README.md
|
@ -5,7 +5,6 @@
|
||||||
Support for server-side caching in [Angel](https://angel-dart.github.io).
|
Support for server-side caching in [Angel](https://angel-dart.github.io).
|
||||||
|
|
||||||
## `CacheService`
|
## `CacheService`
|
||||||
*TODO: Documentation*
|
|
||||||
|
|
||||||
A `Service` class that caches data from one service, storing it in another.
|
A `Service` class that caches data from one service, storing it in another.
|
||||||
An imaginable use case is storing results from MongoDB or another database in
|
An imaginable use case is storing results from MongoDB or another database in
|
||||||
|
@ -17,6 +16,27 @@ A middleware that enables the caching of response serialization.
|
||||||
This can improve the performance of sending objects that are complex to serialize.
|
This can improve the performance of sending objects that are complex to serialize.
|
||||||
You can pass a [shouldCache] callback to determine which values should be cached.
|
You can pass a [shouldCache] callback to determine which values should be cached.
|
||||||
|
|
||||||
|
```dart
|
||||||
|
main() async {
|
||||||
|
var app = new Angel()..lazyParseBodies = true;
|
||||||
|
|
||||||
|
app.use(
|
||||||
|
'/api/todos',
|
||||||
|
new CacheService(
|
||||||
|
database: new AnonymousService(
|
||||||
|
index: ([params]) {
|
||||||
|
print('Fetched directly from the underlying service at ${new DateTime.now()}!');
|
||||||
|
return ['foo', 'bar', 'baz'];
|
||||||
|
},
|
||||||
|
read: (id, [params]) {
|
||||||
|
return {id: '$id at ${new DateTime.now()}'};
|
||||||
|
}
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## `ResponseCache`
|
## `ResponseCache`
|
||||||
A flexible response cache for Angel.
|
A flexible response cache for Angel.
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ class CacheService extends Service {
|
||||||
Future _getCached(Map params, _CachedItem get(), Future getFresh(),
|
Future _getCached(Map params, _CachedItem get(), Future getFresh(),
|
||||||
Future getCached(), Future save(data, DateTime now)) async {
|
Future getCached(), Future save(data, DateTime now)) async {
|
||||||
var cached = get();
|
var cached = get();
|
||||||
//print('$params => $cached');
|
|
||||||
var now = new DateTime.now().toUtc();
|
var now = new DateTime.now().toUtc();
|
||||||
|
|
||||||
if (cached != null) {
|
if (cached != null) {
|
||||||
|
@ -85,7 +84,7 @@ class CacheService extends Service {
|
||||||
() => database.read(id, params),
|
() => database.read(id, params),
|
||||||
() => cache.read(id),
|
() => cache.read(id),
|
||||||
(data, now) async {
|
(data, now) async {
|
||||||
_cache[id] = new _CachedItem(params, now);
|
_cache[id] = new _CachedItem(params, now, data);
|
||||||
return await cache.modify(id, data);
|
return await cache.modify(id, data);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
name: angel_cache
|
name: angel_cache
|
||||||
|
version: 1.0.0
|
||||||
|
homepage: https://github.com/angel-dart/cache
|
||||||
|
description: Support for server-side caching in Angel.
|
||||||
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=1.19.0 <=2.0.0"
|
sdk: ">=1.19.0 <3.0.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
angel_framework: ">=1.0.0-dev <2.0.0"
|
angel_framework: ">=1.0.0-dev <2.0.0"
|
||||||
intl: ^0.15.0
|
intl: ^0.15.0
|
||||||
|
|
Loading…
Reference in a new issue