【问题标题】:How to detect if SimpleDB domain contains the requested item?如何检测 SimpleDB 域是否包含请求的项目?
【发布时间】:2016-10-02 03:56:04
【问题描述】:

Ruby SDK 的AWS SimpleDB documentation 提供了有关使用get_attributes 方法的以下示例:

resp = client.get_attributes({
  domain_name: "String", # required
  item_name: "String", # required
  attribute_names: ["String"],
  consistent_read: false,
})

...然后是以下示例响应:

resp.attributes #=> Array
resp.attributes[0].name #=> String
resp.attributes[0].alternate_name_encoding #=> String
resp.attributes[0].value #=> String
resp.attributes[0].alternate_value_encoding #=> String

它还提出以下建议:

如果此操作访问的副本上不存在该项目,则返回一个空集。系统不会返回错误,因为它不能保证该项目不存在于其他副本上。

我希望我误解了这一点,但是如果您的响应确实返回了一个空集,那么您应该如何知道是因为不存在具有提供的项目名称的项目,还是您的请求只是命中了一个副本不包含您的物品?

【问题讨论】:

    标签: ruby amazon-web-services amazon-simpledb


    【解决方案1】:

    我以前从未使用过 AWS SimpleDB,但根据我对从 Amazon 的 DynamoDB 复制的了解很少,数据通常最终是一致的 - 虽然任何副本都会处理您读取属性的请求,复制先前写入的数据的过程仍然可以在负责存储您的数据的副本中发生,这就是为什么处理您的读取属性请求的副本可能不需要存储数据(但) - 这就是它无法响应错误消息的原因。

    为了 100% 确定,您应该能够指定 consistent_read: true 参数,因为它应该告诉您数据是否存在于 AWS SimpleDB 中:

    根据the documentation of get_attributes method

    :consistent_read (布尔) —

    确定从 SimpleDB 读取数据时是否应强制执行强一致性。如果为 true,则将返回之前写入 SimpleDB 的任何数据。否则,结果最终将是一致的,并且客户端可能看不到在您读取之前立即写入的数据。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-30
      • 2014-10-03
      • 2020-08-10
      • 2015-07-03
      • 2017-04-18
      • 1970-01-01
      相关资源
      最近更新 更多