我有一个 Java Spring 应用程序,其中使用 DynamoDB,到目前为止还没有事务。然而,我最近遇到了一个新的用例,它需要将相关对象持久化在一起。我是这个主题的新手,因此阅读过有关 DynamoDB 事务的内容,但找不到以正确的面向对象方式使用 API 的方法。我缺少什么?
现在,当我需要更新对象时,我按如下方式进行操作,构建一个UpdateItemRequest:
Map<String, AttributeValueUpdate> updates = new HashMap<>();
// fill updates
Map<String, ExpectedAttributeValue> expected = new HashMap<>();
// fill expectations
UpdateItemRequest request = new UpdateItemRequest()
.withTableName(TABLE_NAME)
.withKey(key)
.withAttributeUpdates(updates)
.withExpected(expected);
dynamoDBClient.updateItem(request);
Run Code Online (Sandbox Code Playgroud)
但是,构建交易的文档建议使用以下语法:
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
expressionAttributeValues.put(":new_status", new AttributeValue("SOLD"));
expressionAttributeValues.put(":expected_status", new AttributeValue("IN_STOCK"));
Update markItemSold = new Update()
.withTableName(PRODUCT_TABLE_NAME)
.withKey(productItemKey)
.withUpdateExpression("SET ProductStatus = :new_status")
.withExpressionAttributeValues(expressionAttributeValues)
.withConditionExpression("ProductStatus = :expected_status")
.withReturnValuesOnConditionCheckFailure(ReturnValuesOnConditionCheckFailure.ALL_OLD);
Run Code Online (Sandbox Code Playgroud)
如果我要遵循文档,那么我需要构建一个update expression- 但我坚持的内容可能非常复杂,这将需要一些繁重的字符串操作,这并不令人满意(要制作的解析器会很慢并且容易出错)。
update expression有没有办法从 a获取这个 …
我目前正在学习 Docker,这本书是“使用 Docker”。在第 5 章中,作者从 using 切换docker run到 using docker compose,这permission denied在我的测试应用程序中产生了错误。有什么我可以做的吗?
我用:
1.12.01.8.0, buildd988a55DockerFile :
FROM python:3.4
RUN groupadd -r uwsgi && useradd -r -g uwsgi uwsgi
RUN pip install Flask==0.10.1 uWSGI==2.0.8
WORKDIR /app
COPY app /app
COPY cmd.sh /
EXPOSE 9090 9191
USER uwsgi
CMD ["/cmd.sh"]
Run Code Online (Sandbox Code Playgroud)
docker-compose.yml:
identidock:
build: .
ports:
- "5000:5000"
environment:
ENV: DEV
volumes:
- …Run Code Online (Sandbox Code Playgroud)