自己实现一个缓存
2020-09-24 本文已影响0人
YAOPRINCESS
基本框架
package com.kang.cache;
/**
* @author klr
* @create 2020-09-24-14:53
*/
//集中式缓存
public class MyCache {
//基本功能
public void 设置缓存(Object key, Object value) {
保存数据(key, value);
}
private void 保存数据(Object key, Object value) {
//1.内存
//2.硬盘
//3.第三方应用
}
public Object 读取缓存(Object key) {
return new Object();
}
//扩展功能
public void 清空缓存() {
}
public int 获取缓存数量() {
return 0;
}
public void 溢出淘汰() {
//FIFO
//LRU
//...
}
public void 过期清理() {
}
public void 命中率统计() {
}
}
提高

进阶:经典责任链及变种模式
mybatis缓存的变种责任链


