Skip to content

Updates to work on AWS #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import RedisCache from './helper/RedisCache'

module.exports.hello = async (event, context, callback) => {
context.callbackWaitsForEmptyEventLoop = false

const CACHE_KEY = 'CACHE_KEY'
console.log('event event.pathParameters', event.pathParameters)
const CACHE_KEY = event.pathParameters.proxy
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!'}
await RedisCache.set(CACHE_KEY, {'message': 'Cache response for ' + CACHE_KEY})
res = {'message': 'Set cache success for ' + CACHE_KEY + '!'}
}
const response = {
statusCode: 200,
Expand Down
4 changes: 2 additions & 2 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ service: serverless-elasticache-vpc-nat

provider:
name: aws
runtime: nodejs6.10
runtime: nodejs8.10
region: us-east-2
stage: development
profile: default
Expand Down Expand Up @@ -149,7 +149,7 @@ plugins:
- serverless-offline
custom:
api:
apiPath: "{proxy+}"
apiPath: "{proxy}"
apiMethod: "any"
config:
CACHE_INSTANCE_SIZE: cache.t2.micro
Expand Down