Java 缓存和dynamo db组合存在问题

Java 缓存和dynamo db组合存在问题,java,amazon-web-services,amazon-dynamodb,amazon-elasticache,Java,Amazon Web Services,Amazon Dynamodb,Amazon Elasticache,我使用的是AWS Elasticache,这是我在注释中使用的方法 @Cacheable(unless = "#result != null and #result.size() == 0") public List<SomeObject> findById(String id) { return dynamoDBMapper.query(SomeObject.class, queryExpression(id)); } 看起来它需要PaginatedQueryList类是

我使用的是AWS Elasticache,这是我在注释中使用的方法

@Cacheable(unless = "#result != null and #result.size() == 0")
public List<SomeObject> findById(String id) {
    return dynamoDBMapper.query(SomeObject.class, queryExpression(id));
}
看起来它需要PaginatedQueryList类是可序列化的。虽然我正在尝试缓存列表,但不确定这个分页的QueryList是如何出现的


谢谢你的帮助

PaginatedQueryList是Dynamodb查询方法返回的具体列表实现。您必须将结果复制到列表的可序列化实现中,如ArrayList。

供参考,DynamoDB加速器(DAX)也可能是一个选项。它是DynamoDB前面的托管缓存服务。
DynamoDBQueryExpression<SomeObject> queryExpression(String id) {
    SomeObject object = new SomeObject();
    object.setId(id);
    return new DynamoDBQueryExpression<SomeObject>()
            .withIndexName("idIndex")
            .withConsistentRead(false)
            .withHashKeyValues(object)
            .withLimit(Integer.MAX_VALUE);
}
java.io.NotSerializableException: com.amazonaws.services.dynamodbv2.datamodeling.PaginatedQueryList