1

我使用AWS Elasticache,这里是我与标注使用我不断获取的方法,问题与缓存和发电机分贝组合

@Cacheable(unless = "#result != null and #result.size() == 0") 
public List<SomeObject> findById(String id) { 
    return dynamoDBMapper.query(SomeObject.class, queryExpression(id)); 
} 

这里是我的查询表达式,

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 

看起来像它需要PaginatedQueryList类作为Serializable。虽然我试图缓存List,但不知道这个PaginatedQueryList是如何进入图片的。

感谢帮助!

+0

仅供参考,DynamoDB加速器(DAX)也可能是一个选项。它是DynamoDB之前的托管缓存服务。 – jarmod

回答

2

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