MCPcopy Create free account
hub / github.com/Xiaoc7r/CityHub / testCacheAllShops

Method testCacheAllShops

src/test/java/com/hmdp/ShopCacheTest.java:27–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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}

Callers

nothing calls this directly

Calls 1

setWithLogicalExpireMethod · 0.80

Tested by

no test coverage detected