amazon-web-services - 准备好的代码上的 AWS Elasticache Redis 未在 lambda 中执行
问题描述
这是我写的 lambda
"use strict";
const redis = require('redis');
exports.handler = async (event, context, callback) => {
const client = redis.createClient({url: 'redis://anaha-redis.something.so.0001.meth.ing.amazonaws.com:6379'});
client.on("error", (err) => {
client.quit();
console.log("Redis encountered an error.");
callback(err, null);
});
client.on("ready", () => {
const data = { type: "helloWorld", data: "Hello World!" };
client.publish("testLambda-get-test-helloWorld", JSON.stringify(data));
client.quit();
console.log("HELLLLLOOOOOOOOOOOOOOO",data);
return data;
});
};
但是里面的代码准备就绪并没有被执行。因为 Cloud Watch Logs 没有显示 HELLLLLOOOOOOOOOOOOOOO,因为我已经登录了那部分代码。
我究竟做错了什么?什么是更好的方法?
解决方案
推荐阅读
- node.js - 将任何路由到单个端点并将特定路由到另一个端点?
- css - 反应原生的CSS变换比例
- java - 如何直接从 Java 中的其他类访问内部类方法?
- typescript - Typescript - 函数返回类型作为接口
- xaml - 无法绑定到可绑定属性 [Prism Application Xamarin Forms]
- c++ - 如何控制 Windows 中的应用程序窗口行为?
- python - 使用 boto3 在 Vultr 对象存储上预签名 URL
- php - 在 MAC OS 上将 postgresSQL 与 XAMPP 连接
- r - 如何在 R 中为 HoltWinters 的这个循环添加预测准确性?
- android - Activity 的 LiveData 泄露了 Fragment