mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	bugfix:Spring Cache 自定义过期时间,在多租户场景下,会额外拼接 # 的问题
This commit is contained in:
		| @@ -40,12 +40,15 @@ public class TimeoutRedisCacheManager extends RedisCacheManager { | |||||||
|         // 核心:通过修改 cacheConfig 的过期时间,实现自定义过期时间 |         // 核心:通过修改 cacheConfig 的过期时间,实现自定义过期时间 | ||||||
|         if (cacheConfig != null) { |         if (cacheConfig != null) { | ||||||
|             // 移除 # 后面的 : 以及后面的内容,避免影响解析 |             // 移除 # 后面的 : 以及后面的内容,避免影响解析 | ||||||
|             names[1] = StrUtil.subBefore(names[1], StrUtil.COLON, false); |             String ttlStr = StrUtil.subBefore(names[1], StrUtil.COLON, false); // 获得 ttlStr 时间部分 | ||||||
|  |             names[1] = StrUtil.subAfter(names[1], ttlStr, false); // 移除掉 ttlStr 时间部分 | ||||||
|             // 解析时间 |             // 解析时间 | ||||||
|             Duration duration = parseDuration(names[1]); |             Duration duration = parseDuration(ttlStr); | ||||||
|             cacheConfig = cacheConfig.entryTtl(duration); |             cacheConfig = cacheConfig.entryTtl(duration); | ||||||
|         } |         } | ||||||
|         return super.createRedisCache(name, cacheConfig); |  | ||||||
|  |         // 创建 RedisCache 对象,需要忽略掉 ttlStr | ||||||
|  |         return super.createRedisCache(names[0] + names[1], cacheConfig); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV