Skip to content

Commit f85a735

Browse files
author
Joe Podwys
authoredApr 20, 2019
Update README.md
1 parent b40b031 commit f85a735

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed
 

‎README.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,25 @@ var redisCache = new rcModule({
251251
});
252252
```
253253

254-
# More Usage Examples
255-
## AWS Lambda
256-
If you use `cache-service-redis` in a lambda function with callback make sure to disable `callbackWaitsForEmptyEventLoop` in the lambda context. If this is enabled the lambda function won't terminate.
254+
# Using with AWS Lambda
255+
256+
If you use `cache-service-redis` inside of AWS Lambda, ensure you follow this example so that your lambda process will terminate when complete.
257+
258+
```javascript
259+
exports.handler = function (event, context, callback) {
260+
cache.get(key, function (err, val) {
261+
// handle value
262+
// terminate process with `context`
263+
return context.succeed();
264+
// OR terminate process with `callback`
265+
context.callbackWaitsForEmptyEventLoop = false;
266+
return callback(null);
267+
});
268+
};
269+
```
270+
271+
If you use `cache-service-redis` with `superagent-cache` or `superagent-cache-plugin` inside of AWS Lambda, follow this example.
272+
257273
```javascript
258274
exports.handler = function (event, context, callback) {
259275
superagent

0 commit comments

Comments
 (0)