()
| 25 | private CacheClient cacheClient; |
| 26 | |
| 27 | @Test |
| 28 | public void testCacheAllShops() { |
| 29 | // 1. 从数据库中查询所有店铺信息 |
| 30 | List<Shop> shopList = shopService.list(); |
| 31 | |
| 32 | // 2. 遍历店铺列表,将每个店铺的信息写入Redis |
| 33 | for (Shop shop : shopList) { |
| 34 | // 生成Redis键 |
| 35 | String key = RedisConstants.CACHE_SHOP_KEY + shop.getId(); |
| 36 | |
| 37 | // 将店铺信息写入Redis,并设置逻辑过期时间 |
| 38 | cacheClient.setWithLogicalExpire(key, shop, RedisConstants.CACHE_SHOP_TTL, TimeUnit.HOURS); |
| 39 | } |
| 40 | |
| 41 | System.out.println("All shop information has been cached to Redis."); |
| 42 | } |
| 43 | } |
nothing calls this directly
no test coverage detected