- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
任何人都可以为 Collection 类型推荐一个 Redis (NoSQL DB) 示例吗?通常我们使用以下(在 Spring 中):
@Cacheable(value = "PRODUCT", key = "#productId" )
public Map<String,Object> findProduct(String productId, String productName)
{ return map; }
它将键和值存储为字符串,但我需要:
public Map<RestaurantId,Set<Order>>find(String RestaurantId, String productName){ return map; }
最佳答案
确保您的对象是可序列化的,然后简单地使用 Spring Data Redis cache abstraction ( 2015 link )
从上面的文档中复制的示例:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:c="http://www.springframework.org/schema/c"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:use-pool="true"/>
<!-- redis template definition -->
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"
p:connection-factory-ref="jedisConnectionFactory"/>
<!-- turn on declarative caching -->
<cache:annotation-driven />
<!-- declare Redis Cache Manager -->
<bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager" c:template-ref="redisTemplate"/>
</beans>
关于java - Spring 使用 Redis @Cacheable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20680567/
我正在尝试使用 Spring Cacheable,但遇到了类转换异常 @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(cla
我就废话不多说了,大家还是直接看代码吧~ ? 1
我有这个实用方法来加载我的网络应用程序的内容 @Cacheable(value="dataStrore" ) public MarketJson retrieveMarketJson(DataRequ
与内存数据库一起使用@Cacheable是否相关? 我在内存数据库中使用 h2,只是想知道使用 @Cacheable 可以提高应用程序的性能。我的应用程序将频繁调用数据库中的静态数据 最佳答案 一般来
将 Spring 3.2 与 EhCache 2.9 一起使用。我已经注释了一个零参数方法如下: @Cacheable(value="myList", key="#result.method.name
我正在尝试将 Redis 与 Spring 的 @Cacheable 一起使用,但需要根据 Spring Boot 样式的应用程序属性有条件地打开或关闭缓存。我的第一次尝试似乎没有用。 applica
我在 Spring 3.2 中使用 @Cacheable 来缓存服务层方法的结果。服务类内部使用以下方法代码: @Cacheable("questions") public List getSecut
如何查看@Cacheable 的实现。我想了解他们如何能够获取方法参数的名称并在运行时获取其实际值。 例如: @Cacheable(cacheNames = "name", key = "#k
我正在努力在 Spring Boot 集成测试中测试 @Cacheable。这是我学习如何进行集成测试的第二天,我发现的所有示例都使用旧版本。我还看到了 assetEquals("some value
背景 项目中,使用@Cacheable进行数据缓存。发现:当redis宕机之后,@Cacheable注解的方法并未进行缓存冲突,而是直接抛出异常。而这样的异常会导致服务不可用。 原因分析 我们
我在 Spring 4.1.4 应用程序中使用最新的 Ehcache。我所拥有的是: class Contact{ int id; int revision; } @Cachea
我已经看到很多同一个问题的化身,但我想我已经尝试了所有修复 - 我的用法非常简单。 我一直在使用 Ehcache,但也没有用。因此,为了排除 Ehcache 问题并帮助指出更基本的东西,我转向了 Si
我有一个关于 Spring Security 和 Spring Caching 的问题。假设我有一个方法,并且我已经用 @PreAuthorize("condition") 和 @Cacheable(
我一般用@Cacheable在我的 spring-boot 应用程序中使用缓存配置并为每个缓存设置特定的 TTL(生存时间)。 我最近继承了一个使用 @Cacheable 的 spring boot
我想将一项服务设为可缓存。我一直在研究grails-cache plugin它看起来很有希望,但它导致了一些我不理解的行为。 考虑以下服务: class FooService { def co
我在使用多参数和分页的 @Cacheable 时遇到问题。 @Cacheable(value = "books", key = "#p0") public List findBooks(Long lo
当调用带有 @Cacheable 注释且同步标志设置为 true 的方法时,出现以下异常: java.lang.AbstractMethodError: org.springframework.cac
我已将我的应用程序升级到 Spring 3.1,并且所有 jar 都已充分更新。但是,当我尝试对其中一个 Controller 中的方法使用 @Cacheable 时,该 Controller 的所有
如何进行以下工作? public abstract class MyAbstractOne { @Cacheable(value="myCache") public MyObj
尝试使用内联刷新来实现我自己的缓存加载器。此缓存加载使用 RefreshAheadCacheFactory 如描述 http://terracotta.org/documentation/4.1/bi
我是一名优秀的程序员,十分优秀!