缓存和Dynamo数据库组合问题 [英] Issue with Caching and dynamo db combination

查看:91
本文介绍了缓存和Dynamo数据库组合问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

这是我的查询表达式,

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

看起来它需要PaginatedQueryList类为Serializable。虽然我正在尝试缓存List,但是不确定此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.

提供帮助!

推荐答案

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

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.

这篇关于缓存和Dynamo数据库组合问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆