AWS Elasticache 与周期性任务一起使用
AWS Elasticache use with Periodic Tasks
我正在尝试将 ElastiCache 与 Spring 应用程序一起使用,该应用程序应该作为工作应用程序部署在 AWS 上的工作环境中。
该应用程序有一个 cron 作业,它应该 运行 每 5 分钟并更新 ElastiCache 上的一些数据。 cron.yaml 定义为:
version: 1
cron:
- name: "memcache-dataset-update-job"
url: "/runcron"
schedule: "0/5 * * * *"
"/运行cron" 调用以下方法:
@RequestMapping(method = RequestMethod.GET)
@ResponseStatus(value = HttpStatus.OK)
public void updateDataSet(){
try {
dataSet = initializeNewDataSet();
memcached = new MemcachedClient(new BinaryConnectionFactory(ClientMode.Dynamic),
AddrUtil.getAddresses(memcacheConfigEndpoint));
// Store a value (async) for one hour
memcached.set(dataSetKey, 1800, dataSetObject);
}
我的问题:
1.请求映射应该是httpPOST吗?
2. 我是否需要在 IAM 工作者角色中定义权限以允许我的应用程序访问 ElastiCache。如果是,如何?我在 AWS 文档上找不到任何帮助 here。
我找到了自己问题的答案:
1. 请求映射应该是HTTP POST 方法。
2. ElastiCache 访问无需在 IAM 工作者角色中定义权限。只是该应用程序应该与您的缓存集群位于同一 VPC 中。
我正在尝试将 ElastiCache 与 Spring 应用程序一起使用,该应用程序应该作为工作应用程序部署在 AWS 上的工作环境中。
该应用程序有一个 cron 作业,它应该 运行 每 5 分钟并更新 ElastiCache 上的一些数据。 cron.yaml 定义为:
version: 1
cron:
- name: "memcache-dataset-update-job"
url: "/runcron"
schedule: "0/5 * * * *"
"/运行cron" 调用以下方法:
@RequestMapping(method = RequestMethod.GET)
@ResponseStatus(value = HttpStatus.OK)
public void updateDataSet(){
try {
dataSet = initializeNewDataSet();
memcached = new MemcachedClient(new BinaryConnectionFactory(ClientMode.Dynamic),
AddrUtil.getAddresses(memcacheConfigEndpoint));
// Store a value (async) for one hour
memcached.set(dataSetKey, 1800, dataSetObject);
}
我的问题: 1.请求映射应该是httpPOST吗? 2. 我是否需要在 IAM 工作者角色中定义权限以允许我的应用程序访问 ElastiCache。如果是,如何?我在 AWS 文档上找不到任何帮助 here。
我找到了自己问题的答案: 1. 请求映射应该是HTTP POST 方法。 2. ElastiCache 访问无需在 IAM 工作者角色中定义权限。只是该应用程序应该与您的缓存集群位于同一 VPC 中。