惊讶!缓存刚Put再Get居然获取不到?
最近一直在老家远程办公,微信突然响了下,有同事说遇到了一个奇怪的问题,让我帮忙看下。 现象就是标题所说的缓存获取不到的问题,我一听感觉这个问题挺有意思的,决定一探究竟。 下面给出部分代码还原下案发现场: @CreateCache(name = "demo", expire = 600) private Cache<String, ThirdPartyEventResponse> cache; @Test public void test() { ThirdPartyEventResponse eventResponse = new ThirdPartyEventResponse(); eventResponse.setTicketCategories(Arrays.asList(ticketCategoryResponse)); // 省略 ..... // 添加 cache.put(DisChannelType.PIAONIU.getValue(), eventResponse); // 获取 ThirdPartyEventResponse resp = cache.get(DisChannelType.PIAONIU.getValue()); } Put 之后马上 Get,居然获取不到值。 这就有点匪夷所思了,我们来好好排查下。 首先过期时间为 600 秒