赞
踩
cacheable 把查询出来的数据放到缓存
cacheevict 更新 – >删除模式
cacheput 更新 --> 双写模式
Cacheable() ->value是分区名 key是缓存名
@Configuration @EnableCaching //开启缓存 @EnableConfigurationProperties(CacheProperties.class) //使用redis的容器里面的配置 public class MyCacheConfig { /* @Autowired private CacheProperties cacheProperties;*/ @Bean public RedisCacheConfiguration redisCacheConfiguration(CacheProperties cacheProperties) { RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig(); config = config.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer())); config = config.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer())); CacheProperties.Redis redisProperties = cacheProperties.getRedis(); if (redisProperties.getTimeToLive() != null) { config = config.entryTtl(redisProperties.getTimeToLive()); } if (redisProperties.getKeyPrefix() != null) { config = config.prefixKeysWith(redisProperties.getKeyPrefix()); } if (!redisProperties.isCacheNullValues()) { config = config.disableCachingNullValues(); } if (!redisProperties.isUseKeyPrefix()) { config = config.disableKeyPrefix(); } return config; } }
主配置文件里面的一些基本规则
不能保证强一致性 加的锁不是分布式锁
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。