具有多值查询的Spring Cache Abstraction [英] Spring Cache Abstraction with multi-value queries

查看:109
本文介绍了具有多值查询的Spring Cache Abstraction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Spring Cache抽象是否支持多值查询?

Does Spring Cache abstraction support multi-value queries?

而不是:

@Cacheable(书籍)
public book findBook(ISBN isbn){...}

@Cacheable("books") public Book findBook(ISBN isbn) {...}

想象一下这样的查询:

@Cacheable(books)
public List<书> findBook(列表< ISBN> isbns){...}

@Cacheable("books") public List< Book > findBook(List< ISBN > isbns) {...}

这是否支持?它会单独缓存集合中返回的每本书吗?

Is this supported? Will it individually cache each book returned in the collection?

谢谢!

推荐答案

Spring Cache将整个结果存储在单个缓存键下,因此无法单独存储集合中返回的每个对象。在缓存JPA查询结果的情况下,您可以使用查询缓存。在其他情况下,如果memcached是您的选项,您可以尝试 Simple Spring Memcached 和ReadThroughMultiCache注释。它将在专用缓存键下单独存储集合的每个元素。

Spring Cache stores whole result under single cache key, so it is not possible to store individually each object returned in the collection. In case of caching result of a JPA Query you may use query cache. In other cases if memcached is an option for you, you can try Simple Spring Memcached and ReadThroughMultiCache annotation. It will store each element of the collection individually under dedicated cache key.

这篇关于具有多值查询的Spring Cache Abstraction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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