feat(juhe): 增加Redis缓存与每日调用限流
重构聚合数据客户端为服务层,引入Redis缓存及每日调用上限50次,超限后降级使用缓存;调整默认激活prod并移除MySQL profile;处理静态资源404异常。 添加用户友好界面,增加京备案号
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package com.cyf.devToolBox.juhe.redis;
|
||||
|
||||
/**
|
||||
* 聚合数据相关的 Redis key 统一定义,避免散落在各处。
|
||||
*
|
||||
* <pre>
|
||||
* juhe:weather:{日期}:{城市}:{未来天数} 天气缓存(带 TTL)
|
||||
* juhe:weather:call:{日期} 天气当天调用计数
|
||||
* juhe:soup:pool 每日一句缓存池(Set,永久)
|
||||
* juhe:soup:call:{日期} 每日一句当天调用计数
|
||||
* </pre>
|
||||
*
|
||||
* @author cyf
|
||||
*/
|
||||
public final class JuheRedisKeys {
|
||||
|
||||
private static final String PREFIX = "juhe:";
|
||||
|
||||
private JuheRedisKeys() {
|
||||
}
|
||||
|
||||
/** 天气缓存 key,按「日期 + 城市 + 未来天数」维度缓存。 */
|
||||
public static String weather(String date, String city, Integer futureNum) {
|
||||
return PREFIX + "weather:" + date + ":" + city + ":" + futureNum;
|
||||
}
|
||||
|
||||
/** 天气当天调用计数 key。 */
|
||||
public static String weatherCallCount(String date) {
|
||||
return PREFIX + "weather:call:" + date;
|
||||
}
|
||||
|
||||
/** 每日一句缓存池 key(Set,永久存储,用于去重与随机返回)。 */
|
||||
public static String soupPool() {
|
||||
return PREFIX + "soup:pool";
|
||||
}
|
||||
|
||||
/** 每日一句当天调用计数 key。 */
|
||||
public static String soupCallCount(String date) {
|
||||
return PREFIX + "soup:call:" + date;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user