Skip to content

Commit b40b031

Browse files
author
Joe Podwys
authored
Merge pull request #17 from hottehead/aws-lambda-usage
Add usage example for aws lambda
2 parents 02a6f8d + 2e808ec commit b40b031

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Diff for: README.md

+20
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,23 @@ var redisCache = new rcModule({
250250
backgroundRefreshInterval: 500
251251
});
252252
```
253+
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.
257+
```javascript
258+
exports.handler = function (event, context, callback) {
259+
superagent
260+
.get(uri)
261+
.use(superagentCache)
262+
.end(function (err, response){
263+
// handle response here
264+
// terminate process with `context`
265+
return context.succeed();
266+
// OR terminate process with `callback`
267+
context.callbackWaitsForEmptyEventLoop = false;
268+
return callback(null);
269+
}
270+
);
271+
};
272+
```

0 commit comments

Comments
 (0)