Skip to content

Commit 4c5eda1

Browse files
authored
Merge pull request jaredwray#113 from mingchen/master
Add example of using with async/await
2 parents 107f617 + 57d9d4d commit 4c5eda1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,22 @@ cache = caching({store: store, promiseDependency: Promise});
200200

201201
```
202202
203+
#### Example Using async/await
204+
205+
```javascript
206+
207+
try {
208+
let user = await memoryCache.wrap(key, function() {
209+
return getUserPromise(userId);
210+
});
211+
} catch (err) {
212+
// error handling
213+
}
214+
```
215+
216+
Hint: should wrap `await` call with `try` - `catch` to handle `promise` error.
217+
218+
203219
#### Example Express App Usage
204220
205221
(Also see the [Express.js cache-manager example app](https://github.com/BryanDonovan/node-cache-manager-express-example)).

0 commit comments

Comments
 (0)