Spring_使用缓存cache


1、spring_cache使用缓存

/**

  • 一、搭建基本环境

  • 1、导入数据库文件 创建出department和employee表

  • 2、创建javaBean封装数据

  • 3、整合MyBatis操作数据库

    • 1.配置数据源信息

      • 2.使用注解版的MyBatis;

        • 1)、@MapperScan指定需要扫描的mapper接口所在的包

  • 二、快速体验缓存

    • 步骤:

      • 1、主启动程序开启基于注解的缓存 @EnableCaching

        • 2、标注缓存注解即可

          • @Cacheable

          • @CacheEvict

          • @CachePut

        • 默认使用的是ConcurrentMapCacheManager==ConcurrentMapCache;将数据保存在ConcurrentMap

  • 开发中使用缓存中间件;redis、memcached、ehcache;

相关