我设计了数据访问对象mybatis mapper来读取Mysql数据库中的只读数据。
@Mapper
public interface XYZMapper {
@Select("SELECT TYPES FROM abc WHERE STORE_ID = #{storeId} and CUSTOMER_ID = #{customerId}")
public String getDisabledSubscriptions(@Param("storeId") int storeId, @Param("customerId") int customerId);
@Select("SELECT TYPES as messageTypes, NAME as eventName FROM abc WHERE STORE_ID = #{storeId}")
public EventSubscription getEventAllSubscriptions(@Param("storeId") int storeId);http://mybatis.org/hazelcast-cache/
上面的链接提供了使用hazelcast进行缓存的解决方案。这在我们将映射器配置为xml文件时使用。如何使用注释映射器将上述每个查询缓存为L2缓存
发布于 2020-11-05 16:45:16
通过以下步骤解决了问题
a)使用SpringBootApplication类@EnableCaching
b)在mapper中定义的每个数据库方法中添加@Cacheable ("abc") (您想要缓存)
c)在资源文件夹中定义hazelcast.yml
hazelcast: network: join: multicast: enabled: true
https://stackoverflow.com/questions/64693517
复制相似问题