缓存池-简单实现
来源:互联网 发布:世界地图gis数据 编辑:程序博客网 时间:2024/06/06 03:51
// 测试public class CachePoolTest { public static void main(String[] args) { CachePool c1 = CachePool.valueOf("cachePool"); CachePool c2 = CachePool.valueOf("cachePool"); System.out.println(c1 == c2); }}// 缓存池class CachePool { private static final int MAX_SIZE = 10; private static CachePool[] pool = new CachePool[MAX_SIZE]; private static int pos = 0; // 游标 private final String name; private CachePool(String name) { this.name = name; } public String getName() { return name; } public static CachePool valueOf(String name) { for (CachePool cache : pool) { if(cache != null && cache.name.equals(name)) { return cache; } } if(pos == MAX_SIZE) { // 先进先出原则 pool[0] = new CachePool(name); pos = 1; } else { // 等价于赋值pool[pos]后,pos后移1 pool[pos++] = new CachePool(name); } return pool[pos-1]; }}
0 0
- 缓存池-简单实现
- 简单缓存实现
- 简单缓存的实现
- 简单实现本地缓存
- map实现简单缓存
- 简单LRU算法实现缓存
- HASHMAP缓存简单java实现
- java缓存的简单实现
- Lru缓存的简单实现
- 简单LRU算法实现缓存
- 简单的LRU缓存实现
- 简单的java缓存实现
- 简单的java缓存实现
- 简单LRU算法实现缓存
- 简单LRU算法实现缓存
- 用Map实现简单缓存
- 缓存的简单实现例子
- Android 简单实现缓存机制
- Linux Mysql 定时自动备份
- flask
- BufferedInputStream与BufferedOutputStream复制文件
- PHP创建和添加压缩文件
- poj1155 TELE 【树形dp】
- 缓存池-简单实现
- 暑假留校--第一周总结
- 滥用单例之dispatch_once死锁
- 异常简单处理的4种方法
- js闭包的理解以及闭包中this的理解
- HDOJ 5753 (2016多校联合训练 Training Contest 3) Permutation Bo
- 计算机网络面试相关
- java中trim的理解
- Struts2 - 常用的constant总结