Issue with Caching and dynamo db combination

房东的猫 提交于 2019-12-11 10:28:18

问题


I am using AWS Elasticache and here is the method I am using with annotation,

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

Here is my query expression,

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);
}

I keep on getting this error in my application log,

java.io.NotSerializableException: com.amazonaws.services.dynamodbv2.datamodeling.PaginatedQueryList

Looks like it needs the PaginatedQueryList class as Serializable. Though I am trying to cache List, not sure how this PaginatedQueryList is coming into the picture.

Appreciate help!


回答1:


PaginatedQueryList is the concrete List implementation returned by Dynamodb's query method. You'll have to copy your results into a serializable implementation of List, like ArrayList.



来源:https://stackoverflow.com/questions/45495145/issue-with-caching-and-dynamo-db-combination

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!