-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathhandler.js
More file actions
26 lines (21 loc) · 727 Bytes
/
handler.js
File metadata and controls
26 lines (21 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict'
import RedisCache from './helper/RedisCache'
module.exports.hello = async (event, context, callback) => {
context.callbackWaitsForEmptyEventLoop = false
const CACHE_KEY = 'CACHE_KEY'
let res = {}
let checkCache = await RedisCache.get(CACHE_KEY)
if (checkCache) {
res = checkCache
} else {
await RedisCache.set(CACHE_KEY, {'message': 'Hello World!'})
res = {'message': 'Set cache success!'}
}
const response = {
statusCode: 200,
body: JSON.stringify(res)
}
callback(null, response)
// Use this code if you don't use the http event with the LAMBDA-PROXY integration
// callback(null, { message: 'Go Serverless v1.0! Your function executed successfully!', event });
}