redis场景
- 缓存
- 接口幂等(setnx)
- 限流、延时队列(zset)
- 分布式锁(setnx+expire)
- 网站页面访问量(hyperLogLog)
- 布隆过滤器(位图+哈希)
分库分表
按场景选,不要只看数据量:
-
单一增长、低增长、低并发:优化搞定不用拆
-
高并发写、多维度查、数据暴涨:必须分库分表
jwt
- 服务端不保存已签发的JWT,所以无法主动撤销已签发的JWT,要想撤销可以加一个黑名单
- juejin.cn/post/705109…
动态代理
- 分为jdk动态代理和cglib动态代理
- juejin.cn/post/743643…
双重检查锁
public class Singleton {
private static volatile Singleton instance = null;
private Singleton() {}
public static Singleton getInstance() {
if (instance == null) {
synchronized (Singleton.class) {
if (instance == null) {
instance = new Singleton();
}
}
}
return instance;
}
}